| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using OHV.Common.Model;
- using OHV.Common.Shareds;
- namespace OHV.SqliteDAL.DAL
- {
- public class CommandDAL : GenericDAL<Command>
- {
- public Command GetCmd()
- {
- Command cmd;
- using (var db = new OHVDbContext("OHVDb"))
- {
- cmd = db.Set<Command>().FirstOrDefault();
- }
- return cmd;
- }
- public void UpdateState(string id, eCommandState state)
- {
- using (var db = new OHVDbContext("OHVDb"))
- {
- var cmd = db.Set<Command>().Where(c => c.CommandID.Equals(id)).SingleOrDefault();
- cmd.State = state;
- db.SaveChanges();
- }
- }
- public void UpdateResult(string id, eCommandResult result)
- {
- using (var db = new OHVDbContext("OHVDb"))
- {
- var cmd = db.Set<Command>().Where(c => c.CommandID.Equals(id)).SingleOrDefault();
- cmd.Result = result;
- db.SaveChanges();
- }
- }
- public int GetCount()
- {
- int count = 0;
- using (var db = new OHVDbContext("OHVDb"))
- {
- count = db.Set<Command>().Count();
- }
- return count;
- }
- }
- }
|