public Model.Discipline Update(Model.Discipline entity) { Delete(entity.Id); Save(entity); return(entity); }
public DisciplineResult Find(long id) { Model.Discipline entity = Dao.Find(id); DisciplineResult result = ResultConverter.Convert(entity); return(result); }
public Model.Discipline Save(Model.Discipline entity) { DisciplineDaoStorage.Disciplines.Add(entity); DisciplineDaoStorage.Dictionary.Add(entity.Id, entity); return(entity); }
static DisciplineDaoStorage() { Model.Discipline Discipline1 = new Model.Discipline() { Id = 1, Description = ".NET ASP", Code = "1", Name = "Discipline", }; Model.Discipline Discipline2 = new Model.Discipline() { Id = 2, Description = "mathematics", Code = "2", Name = "Discipline " }; Model.Discipline Discipline3 = new Model.Discipline() { Id = 3, Description = "Data base", Code = "3", Name = "Discipline" }; Disciplines.Add(Discipline1); Disciplines.Add(Discipline2); Disciplines.Add(Discipline3); Dictionary.Add(Discipline1.Id, Discipline1); Dictionary.Add(Discipline2.Id, Discipline2); Dictionary.Add(Discipline3.Id, Discipline3); }
//public DisciplineProcessor(IDisciplineDao dao, IDisciplineParamConverter paramConverter, // IDisciplineResultConverter resultConverter) //{ // this.Dao = dao; // this.ParamConverter = paramConverter; // this.ResultConverter = resultConverter; //} public DisciplineResult Create(DisciplineParam param) { Model.Discipline entity = ParamConverter.Convert(param, null); entity = Dao.Save(entity); return(ResultConverter.Convert(entity)); }
public void Update(List <DisciplineParam> param) { //List<UniversityDemo.Discipline> entities = new List<UniversityDemo.Discipline>(); foreach (var item in param) { Model.Discipline oldEntity = Dao.Find(item.Id); Model.Discipline newEntity = ParamConverter.Convert(item, null); Dao.Update(newEntity); } }
public void Update(long id, DisciplineParam param) { Model.Discipline oldEntity = Dao.Find(id); if (oldEntity != null) { Dao.Delete(oldEntity); Dao.Update(ParamConverter.Convert(param, null)); } else { Console.WriteLine($"No entity with Id = {id} was found"); } }
public DisciplineResult Convert(Model.Discipline param) { DisciplineResult result = new DisciplineResult() { Id = param.Id, Code = param.Code, Name = param.Name, Description = param.Description, StatusId = param.Status.Id, StatusName = param.Status.Name }; return(result); }
public Model.Discipline Convert(DisciplineParam param, Model.Discipline oldEntity) { Model.Discipline entity = null; if (oldEntity != null) { entity = oldEntity; } else { entity = new Model.Discipline { Code = param.Code, Id = param.Id, Description = param.Description, Name = param.Name }; } entity.Status = StatusDao.Find(param.StatusId); return(entity); }
public void Delete(Model.Discipline entity) { DisciplineDaoStorage.Disciplines.Remove(entity); DisciplineDaoStorage.Dictionary.Remove(entity.Id); }
public void Delete(long id) { Model.Discipline entity = Find(id); Delete(entity); }