public LaborDto Update(LaborDto dto) { Labor labor = Map(dto); _context.Labors.Update(labor); _context.SaveChanges(); return(Map(labor)); }
public LaborDto Add(LaborDto dto) { Labor labor = Map(dto); _context.Labors.Add(labor); _context.SaveChanges(); return(Map(labor)); }
public void Update(LaborDto dto) { using (var db = new DbContext()) { Entities.Labor labor = db.Labor.Single(x => x.Id == dto.Id); labor.HuntsmanId = dto.HuntsmanId; labor.Description = dto.Description; labor.Date = dto.Date; db.SaveChanges(); } }
public void Insert(LaborDto dto) { var entity = new Entities.Labor { HuntsmanId = dto.HuntsmanId, Description = dto.Description, Date = dto.Date }; using (var db = new DbContext()) { db.Labor.Add(entity); db.SaveChanges(); } }
public void AddLabor(LaborViewModel model, int marketingYearId) { if (model.HuntsmanId <= 0 || String.IsNullOrWhiteSpace(model.Description)) { throw new Exception("Nie można dodać pracy gospodarczej"); } var dto = new LaborDto { HuntsmanId = model.HuntsmanId, Description = model.Description, Date = model.Date }; _laborDao.Insert(dto); }
private IList <LaborDto> ToDtos(IList <Entities.Labor> entityList) { var dtos = new List <LaborDto>(); foreach (Entities.Labor entity in entityList) { var dto = new LaborDto { Id = entity.Id, HuntsmanId = entity.HuntsmanId, Description = entity.Description, Date = entity.Date }; dtos.Add(dto); } return(dtos); }
public Labor Map(LaborDto dto) { Labor labor = _context.Labors.FirstOrDefault(x => x.Id == dto.Id); if (labor == null) { labor = new Labor(); } labor.ProjectId = dto.ProjectId; labor.TaskNumber = dto.TaskNumber; labor.TaskName = dto.TaskName; labor.Type = (TaskType)dto.Type; labor.Priority = (TaskPriority)dto.Priority; labor.EstimatedTime = dto.EstimatedTime; labor.ElapsedTime = dto.ElapsedTime; labor.Note = dto.Note; labor.UserId = dto.UserId; labor.Date = dto.Date; labor.TaskModelId = dto.TaskModelId; return(labor); }
public LaborDto Update([FromBody] LaborDto dto) { return(_laborsService.Update(dto)); }
public LaborDto Add([FromBody] LaborDto dto) { return(_laborsService.Add(dto)); }