public static void Create(ProjectStatusDto dto) { using (var db = new MainDBModelContainer()) { var entity = ProjectStatusMapper.DtoToEntity(dto); db.ProjectStatusSet.Add(entity); db.SaveChanges(); } }
public static void Update(ProjectStatusDto dto) { using (var db = new MainDBModelContainer()) { var newData = ProjectStatusMapper.DtoToEntity(dto); var oldData = db.ProjectStatusSet.Find(dto.Id); if (oldData != null) { oldData.Name = newData.Name; db.SaveChanges(); } else { throw new ElementNotFoundException(); } } }