Ejemplo n.º 1
0
        public async Task <IActionResult> Update(TariffDTO tariffDto, int id)
        {
            var tariff = _mapper.Map <Tariff>(tariffDto);
            await _tariffService.Update(tariff, id);

            return(Ok(tariff));
        }
Ejemplo n.º 2
0
        public async Task Get_Tariff_CorrectData()
        {
            Assert.IsNotNull(_testTariffId, "The testProduct id has to be defined");
            TariffDTO tariffDTO = await _tariffService.Get(_testTariffId);

            Assert.IsNotNull(tariffDTO, "Test tariff NOT found!");
            Assert.AreEqual(_baseCostsAnnualTest, tariffDTO.BaseCostsAnnual, "Something is wrong with your search. Annual costs do not equal.");
            Assert.NotNull(tariffDTO.NextPricingTier, "Next pricing tier should be defined, got null.");
            Assert.AreEqual(_consumptionCostsPerKwHNextTier, tariffDTO.NextPricingTier.ConsumptionCostsPerKWh, "The next pricing tier seems to wrong. Consumption per kWh does not match.");
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> Get(Guid id)
        {
            _logger.LogDebug("GetTariffById called..");
            TariffDTO tariff = await _tariffService.Get(id);

            if (tariff == null)
            {
                return(NotFound());
            }
            return(Ok(tariff));
        }
Ejemplo n.º 4
0
        public async Task <ActionResult> ConfirmTariff(TariffDTO dto)
        {
            var tariff = await tariffService.GetTariffDTO(dto.FlatId, dto.TypeOfServiceId);

            if (tariff != null)
            {
                await tariffService.DeleteTariff(tariff.TariffId);
            }
            await tariffService.CreateTariff(dto);

            return(RedirectToAction("SelectService", new { flatId = dto.FlatId }));
        }
Ejemplo n.º 5
0
        public ActionResult Create(TariffDTO model)
        {
            try
            {
                _tariffService.Create(model);

                return(RedirectToAction(nameof(Index)));
            }
            catch
            {
                ModelState.AddModelError(string.Empty, "Введены неправильные данные");
                return(View(model));
            }
        }
Ejemplo n.º 6
0
 public IActionResult PostTariff([FromBody] TariffDTO tariffDto)
 {
     try
     {
         var tariff = _mapper.Map <Tariff>(tariffDto);
         tariff.UserId = Convert.ToInt32(_httpContextAccessor.HttpContext.User.Identity.Name);
         return(Ok(new { status = _newsService.PostTariff(tariff) }));
     }
     catch (AppException ex)
     {
         // return error message if there was an exception
         return(Ok(new { code = false, message = ex.Message }));
     }
 }
Ejemplo n.º 7
0
        public async Task CreateTariff(TariffDTO dto)
        {
            Guid id = Guid.NewGuid();

            using (MUEContext db = new MUEContext())
            {
                Tariff tariff = new Tariff
                {
                    Value           = dto.Value,
                    TypeOfServiceId = dto.TypeOfServiceId,
                    TariffId        = id,
                    FlatId          = dto.FlatId
                };
                db.Tariffs.Add(tariff);
                await db.SaveChangesAsync();
            }
        }
Ejemplo n.º 8
0
 public void Update(TariffDTO item)
 {
     Database.Tariffs.Update(Mapper.Map <Tariff>(item));
     Database.Save();
 }
Ejemplo n.º 9
0
        protected override void Seed(DatabaseContext context)
        {
            // Here you can seed your core data if you have any.
            var baseTariff = new TariffDTO()
            {
                Name  = "base Tariff",
                Price = 4.0
            };
            var dayTariff = new TariffDTO()
            {
                Name  = "Day Tariff",
                Price = 4.2
            };
            var nightTariff = new TariffDTO()
            {
                Name  = "Night Tariff",
                Price = 4.2
            };

            context.TariffDTOs.Add(baseTariff);
            context.TariffDTOs.Add(dayTariff);
            context.TariffDTOs.Add(nightTariff);

            var meterType = new MeterTypeDTO()
            {
                ManufacturerName     = "Meteor",
                ModelName            = "Signal 01",
                CalibrationIntervals = 10
            };

            var fistAgreement = new AgreementDTO()
            {
                Name    = "First",
                Number  = "01-01-2018",
                BegDate = new DateTime(2018, 3, 1),
                EndDate = new DateTime(2020, 3, 1),
                Deleted = false
            };

            var secondAgr = new AgreementDTO()
            {
                Name    = "Second (deleted)",
                Number  = "01-01-2018",
                BegDate = new DateTime(2018, 3, 1),
                EndDate = new DateTime(2020, 3, 1),
                Deleted = true
            };

            context.AgreementDTOs.Add(fistAgreement);
            context.AgreementDTOs.Add(secondAgr);

            var unitHouse = new UnitDTO()
            {
                Name   = "House",
                Adress = "Moscow 1"
            };

            var unitStore = new UnitDTO()
            {
                Name   = "Store",
                Adress = "Novgorod 1"
            };

            context.UnitDTOs.Add(unitHouse);
            context.UnitDTOs.Add(unitStore);
            context.LinkObjectsDTOs.Add(new LinkObjectsDTO()
            {
                Owner     = fistAgreement,
                Childen   = unitHouse,
                BeginDate = new DateTime(2018, 1, 1),
                EndDate   = new DateTime(2079, 1, 1),
                Factore   = 1.0,
            });
            context.LinkObjectsDTOs.Add(new LinkObjectsDTO()
            {
                Owner     = fistAgreement,
                Childen   = unitStore,
                BeginDate = new DateTime(2018, 1, 1),
                EndDate   = new DateTime(2079, 1, 1),
                Factore   = 0.5
            });

            var tariffGroupHouse = new TariffGroupDTO()
            {
                Name   = "Base Tariff House",
                Tariff = baseTariff
            };
            var tariffGroupStore = new TariffGroupDTO()
            {
                Name   = "Base Tariff Store",
                Tariff = baseTariff
            };

            context.TariffGroupDTOs.Add(tariffGroupHouse);
            context.TariffGroupDTOs.Add(tariffGroupStore);
            context.LinkObjectsDTOs.Add(new LinkObjectsDTO()
            {
                Owner     = unitHouse,
                Childen   = tariffGroupHouse,
                BeginDate = new DateTime(2018, 1, 1),
                EndDate   = new DateTime(2079, 1, 1),
                Factore   = 1.0
            });
            context.LinkObjectsDTOs.Add(new LinkObjectsDTO()
            {
                Owner     = unitStore,
                Childen   = tariffGroupStore,
                BeginDate = new DateTime(2018, 1, 1),
                EndDate   = new DateTime(2079, 1, 1),
                Factore   = 1.0
            });

            var channelHouse = new ChannelDTO()
            {
                Name           = "Base Channel",
                VoltageLevelId = 0
            };

            context.ChannelDTOs.Add(channelHouse);
            context.LinkObjectsDTOs.Add(new LinkObjectsDTO()
            {
                Owner     = tariffGroupHouse,
                Childen   = channelHouse,
                BeginDate = new DateTime(2018, 1, 1),
                EndDate   = new DateTime(2079, 1, 1),
                Factore   = 1.0
            });

            var consFlowStore = new ConstantFlowDTO()
            {
                Name           = "Signal system",
                VoltageLevelId = 0,
                Сonsumption    = 10.0
            };

            context.ConstantFlowDTOs.Add(consFlowStore);
            context.LinkObjectsDTOs.Add(new LinkObjectsDTO()
            {
                Owner     = tariffGroupStore,
                Childen   = consFlowStore,
                BeginDate = new DateTime(2018, 1, 1),
                EndDate   = new DateTime(2079, 1, 1),
                Factore   = 1.0
            });

            var meterHouse = new MeterDTO()
            {
                Name         = "ground flow",
                CountScale   = 6,
                PublicNumber = "34785",
                SerialNumber = "2016-04-23-02-2349"
            };

            context.MeterDTOs.Add(meterHouse);
            context.LinkObjectsDTOs.Add(new LinkObjectsDTO()
            {
                Owner     = channelHouse,
                Childen   = meterHouse,
                BeginDate = new DateTime(2018, 1, 1),
                EndDate   = new DateTime(2079, 1, 1),
                Factore   = 1.0
            });

            var scaleHouse = new MeterScaleDTO()
            {
                Name        = "All day",
                Dimension   = 6,
                ZoneOfDayId = 0
            };

            context.MeterScaleDTOs.Add(scaleHouse);
            context.LinkObjectsDTOs.Add(new LinkObjectsDTO()
            {
                Owner     = meterHouse,
                Childen   = scaleHouse,
                BeginDate = new DateTime(2018, 1, 1),
                EndDate   = new DateTime(2079, 1, 1),
                Factore   = 1.0
            });

            context.IndicationDocumentDTOs.Add(new Models.Documents.IndicationDocumentDTO()
            {
                CreateDate  = new DateTime(2018, 1, 1),
                ReceiptDate = new DateTime(2018, 1, 1),
                Meter       = meterHouse,
                Scale       = scaleHouse,
                Indication  = 1012
            });

            context.IndicationDocumentDTOs.Add(new Models.Documents.IndicationDocumentDTO()
            {
                CreateDate  = new DateTime(2018, 2, 1),
                ReceiptDate = new DateTime(2018, 2, 1),
                Meter       = meterHouse,
                Scale       = scaleHouse,
                Indication  = 1057
            });

            context.IndicationDocumentDTOs.Add(new Models.Documents.IndicationDocumentDTO()
            {
                CreateDate  = new DateTime(2018, 3, 1),
                ReceiptDate = new DateTime(2018, 3, 1),
                Meter       = meterHouse,
                Scale       = scaleHouse,
                Indication  = 1135
            });

            context.IndicationDocumentDTOs.Add(new Models.Documents.IndicationDocumentDTO()
            {
                CreateDate  = new DateTime(2018, 4, 1),
                ReceiptDate = new DateTime(2018, 4, 1),
                Meter       = meterHouse,
                Scale       = scaleHouse,
                Indication  = 1208
            });
        }
Ejemplo n.º 10
0
 public async Task Add(TariffDTO tariffDto)
 {
     var tariff = _mapper.Map <Tariff>(tariffDto);
     await _tariffService.Create(tariff);
 }