Example #1
0
        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);
        }
Example #2
0
        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();
            }
        }
Example #3
0
        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();
            }
        }
Example #4
0
        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);
        }
Example #5
0
        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);
        }