public void UpdateCarcassRevenue(CarcassRevenueViewModel model, int marketingYearId) { var dto = new CarcassRevenueDto { Id = model.Id, HuntedGameId = model.HuntedGameId, CarcassWeight = model.CarcassWeight, Revenue = model.Revenue }; _carcassRevenueDao.Update(dto); }
public void Update(CarcassRevenueDto dto) { using (var db = new DbContext()) { Entities.CarcassRevenue carcassRevenue = db.CarcassRevenue.Single(x => x.Id == dto.Id); carcassRevenue.HuntedGameId = dto.HuntedGameId; carcassRevenue.Revenue = dto.Revenue; carcassRevenue.CarcassWeight = dto.CarcassWeight; db.SaveChanges(); } }
public void Insert(CarcassRevenueDto dto) { var entity = new Entities.CarcassRevenue { HuntedGameId = dto.HuntedGameId, Revenue = dto.Revenue, CarcassWeight = dto.CarcassWeight }; using (var db = new DbContext()) { db.CarcassRevenue.Add(entity); db.SaveChanges(); } }
private IList <CarcassRevenueDto> ToDtos(IList <Entities.CarcassRevenue> entityList) { var dtos = new List <CarcassRevenueDto>(); foreach (Entities.CarcassRevenue entity in entityList) { var dto = new CarcassRevenueDto { Id = entity.Id, HuntedGameId = entity.HuntedGameId, Revenue = entity.Revenue, CarcassWeight = entity.CarcassWeight }; dtos.Add(dto); } return(dtos); }
public void AddCarcassRevenue(CarcassRevenueViewModel model, int marketingYearId) { IList <CarcassRevenueDto> existingCarcassRevenueDtos = _carcassRevenueDao.GetByMarketingYear(marketingYearId); if (existingCarcassRevenueDtos.Any(x => x.HuntedGameId == model.HuntedGameId)) { throw new Exception("Podana zwierzyna została już wcześniej użyta do rozliczenia przychodu. Proszę wybrać inną zwierzynę lub edytować istniejący przychód."); } var dto = new CarcassRevenueDto { HuntedGameId = model.HuntedGameId, CarcassWeight = model.CarcassWeight, Revenue = model.Revenue }; _carcassRevenueDao.Insert(dto); }