public async Task <IActionResult> UpdateTariff([FromRoute] int id, [FromBody] TariffPlan tar) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var item = _context.TariffPlans.Find(id); if (item == null) { return(NotFound()); } //блок перезаписи данных item.Name = tar.Name; item.CanConnectThisTar = tar.CanConnectThisTar; item.CostChangeTar = tar.CostChangeTar; item.CostOneMinCallCity = tar.CostOneMinCallCity; item.CostOneMinCallInternation = tar.CostOneMinCallInternation; item.CostOneMinCallOutCity = tar.CostOneMinCallOutCity; item.CostSms = tar.CostSms; item.FreeMinuteForMonth = tar.FreeMinuteForMonth; item.IntGb = tar.IntGb; item.IsPhysTar = tar.IsPhysTar; item.SubcriptionFee = tar.SubcriptionFee; _context.TariffPlans.Update(item); await _context.SaveChangesAsync(); return(NoContent()); }
public CallCompletedEventArgs(long senderNumber, long receiverNumber, TariffPlan plan) { SenderNumber = senderNumber; ReceiverNumber = receiverNumber; CallDuration = new Random().Next(1, 3601); Plan = plan ?? throw new ArgumentNullException(nameof(plan)); }
public User MakeUser(string name, TariffPlan tariff) { return(new User() { Name = name, Tariff = tariff }); }
public Contract(Client client, TariffType tariffType, DateTime conclusionDate) { LastTariffUpdateDate = DateTime.Now; Client = client; PhoneNumber = new PhoneNumber(rnd.Next(1000000, 9999999).ToString()); TariffPlan = new TariffPlan(tariffType); ConclusionDate = conclusionDate; }
static void Main(string[] args) { IStation _Station = new Station(); ICompany Company = new Billing.Company_.Company("Белтелеком", _Station); ITariffPlan TarriffPlan = new TariffPlan(); IPort port1 = _Station.GetFreePort(); IClientTerminal terminal1 = _Station.GetClientTerminal(111111); IClient Client1 = new Billing.Client_.Client("Вася", "Пупкин", "10.10.1990"); Company.ClientHandler.Contracts.Add(new Contract(Company, Client1, DateTime.Now, TarriffPlan)); Client1.AcceptClientTerminalAndPort(terminal1, port1, TarriffPlan); Client1.PlugClientTerminalInPort(); IPort port2 = _Station.GetFreePort(); IClientTerminal terminal2 = _Station.GetClientTerminal(222222); IClient Client2 = new Billing.Client_.Client("Федя", "Тапкин", "11.11.1995"); Company.ClientHandler.Contracts.Add(new Contract(Company, Client2, DateTime.Now, TarriffPlan)); Client2.AcceptClientTerminalAndPort(terminal2, port2, TarriffPlan); Client2.PlugClientTerminalInPort(); IPort port3 = _Station.GetFreePort(); IClientTerminal terminal3 = _Station.GetClientTerminal(333333); IClient Client3 = new Billing.Client_.Client("Афоня", "Сковородкин", "11.11.2000"); Company.ClientHandler.Contracts.Add(new Contract(Company, Client3, DateTime.Now, TarriffPlan)); Client3.AcceptClientTerminalAndPort(terminal3, port3, TarriffPlan); Client3.PlugClientTerminalInPort(); Client1.ClientTerminal.OutgoingCall(222222); Thread.Sleep(5000); Client1.ClientTerminal.FinishConversation(); Client1.ClientTerminal.OutgoingCall(333333); Thread.Sleep(7000); Client3.ClientTerminal.FinishConversation(); Client2.ClientTerminal.OutgoingCall(111111); Thread.Sleep(10000); Client2.ClientTerminal.FinishConversation(); Company.ClientHandler.GetDetailedСallReportForReportPeriod(Client1); Company.ClientHandler.GetDetailedСallReportByCallDate(); Company.ClientHandler.GetDetailedСallReportByClient(Client1); Company.ClientHandler.GetDetailedСallReportByCallCost(); Console.ReadKey(); }
public IActionResult Edit(TariffPlan tariffPlan) { if (ModelState.IsValid) { db.TariffPlans.Update(tariffPlan); db.SaveChanges(); } return(RedirectToAction(nameof(Index))); }
public async Task <IActionResult> CreateNewTariff([FromBody] TariffPlan tar) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _context.TariffPlans.Add(tar); await _context.SaveChangesAsync(); return(CreatedAtAction("GetTariff", new { id = tar.Id }, tar)); }
public void ChangeTariffPlan(TariffPlan plan) { if ((plan.DateConnection - this.TariffPlan.DateConnection).Days > 30) { TariffPlan = plan; } else { throw new Exception("Unable to change the tariff plan."); } }
public void Subscribe(PhoneStation station, TariffPlan plan) { if (station == null) { throw new ArgumentNullException(nameof(station)); } if (plan == null) { throw new ArgumentNullException(nameof(plan)); } PhoneNumber = station.AddSubscriber(this, plan); }
public TariffPlanModel(TariffPlan tariff) { id = tariff.id; name = tariff.name; costOneMinCallCity = tariff.costOneMinCallCity; costOneMinCallOutCity = tariff.costOneMinCallOutCity; CostOneMinCallInternation = tariff.CostOneMinCallInternation; costSms = tariff.costSms; intGB = tariff.intGB; SMS = tariff.SMS; subscriptionFee = tariff.subcriptionFee; isPhysTar = tariff.isPhysTar; costChangeTar = tariff.costChangeTar; CanConnectThisTar = tariff.CanConnectThisTar; freeMinuteForMonth = tariff.freeMinuteForMonth; }
public long AddSubscriber(Subscriber subscriber, TariffPlan plan) { if (subscriber == null) { throw new ArgumentNullException(nameof(subscriber)); } if (plan == null) { throw new ArgumentNullException(nameof(plan)); } var number = GenerateNumber(_prefix, 4); var port = new Port(number); port.PortStateChanged += OnPortStateChanged; _subscribers.Add(new Entry(port, subscriber, plan)); return(number); }
public TariffPlanModel GetItemTariffPlan(string name) { TariffPlan c = db.TariffPlan.ToList().Where(i => i.name.Trim() == name.Trim()).FirstOrDefault(); return(new TariffPlanModel() { freeMinuteForMonth = c.freeMinuteForMonth, name = c.name, id = c.id, CanConnectThisTar = c.CanConnectThisTar, costChangeTar = c.costChangeTar, costOneMinCallCity = c.costOneMinCallCity, CostOneMinCallInternation = c.CostOneMinCallInternation, costOneMinCallOutCity = c.costOneMinCallOutCity, intGB = c.intGB, isPhysTar = c.isPhysTar, SMS = c.SMS, subscriptionFee = c.subcriptionFee, costSms = c.costSms }); }
public static TariffPlan[] TariffPlans(int count) { string[] titlePlan = { "Грузовой", "Легковой" }; string[] description = { "Большой тонаж", "Мелкий тонаж" }; TariffPlan[] tariffPlans = new TariffPlan[count]; Random rand = new Random(); for (int i = 0; i < count; i++) { tariffPlans[i] = new TariffPlan { Id = i + 1, TitlePlan = titlePlan[rand.Next(0, titlePlan.Length)], Description = description[rand.Next(0, description.Length)], CostPlan = rand.Next(100, 100000) + rand.NextDouble() }; } return(tariffPlans); }
public void UpdateConnectTariff(int idClient, int idTariff) { ConnectTariff connect = db.ConnectTariff.ToList().Where(i => i.idClient == idClient && i.dateConnectTariffEnd == null).FirstOrDefault(); connect.dateConnectTariffEnd = DateTime.Now; ConnectTariff newConnect = new ConnectTariff() { idClient = idClient, dateConnectTariffBegin = DateTime.Now, dateConnectTariffEnd = null, idTariffPlan = idTariff }; db.ConnectTariff.Add(newConnect); TariffPlan c = db.TariffPlan.ToList().Where(i => i.id == idTariff).FirstOrDefault(); Client client = db.Client.Find(idClient); client.freeMin = c.freeMinuteForMonth; client.freeGB = c.intGB; client.freeSms = c.SMS; Save(); }
public TariffPlanModel GetActiveTariff(int idClient) { ConnectTariff connect = db.ConnectTariff.ToList().Where(i => i.idClient == idClient && i.dateConnectTariffEnd == null).FirstOrDefault(); TariffPlan tariffPlan = db.TariffPlan.ToList().Where(i => i.id == connect.idTariffPlan).FirstOrDefault(); return(new TariffPlanModel() { freeMinuteForMonth = tariffPlan.freeMinuteForMonth, name = tariffPlan.name, id = tariffPlan.id, CanConnectThisTar = tariffPlan.CanConnectThisTar, costChangeTar = tariffPlan.costChangeTar, costOneMinCallCity = tariffPlan.costOneMinCallCity, CostOneMinCallInternation = tariffPlan.CostOneMinCallInternation, costOneMinCallOutCity = tariffPlan.costOneMinCallOutCity, costSms = tariffPlan.costSms, intGB = tariffPlan.intGB, isPhysTar = tariffPlan.isPhysTar, SMS = tariffPlan.SMS, subscriptionFee = tariffPlan.subcriptionFee }); }
public ActionResult EditTariffPlan(int?id) { try { ViewBag.TariffTypes = data.TariffTypeRepos.GetAll(); TariffPlan model = new TariffPlan(); if (id != null) { ViewBag.Id = id; model = data.TariffPlanRepos.GetById((int)id); ViewBag.PlanTypes = model.Types; } return(View(new TariffPlanViewModel() { Description = model.Description, ShortDesc = model.ShortDesc, DiscWillEnd = model.DiscWillEnd })); } catch (Exception) { return(HttpNotFound()); } }
public ActionResult EditTariffPlan(TariffPlanViewModel tariffPlanViewModel, int?id, int[] Types) { try { if (Types == null) { ModelState.AddModelError("DiscWillEnd", "Укажите хотябы один тип тарифа"); } if (ModelState.IsValid) { TariffPlan ob = data.TariffPlanRepos.GetById((int)id); ob.Description = tariffPlanViewModel.Description; ob.ShortDesc = tariffPlanViewModel.ShortDesc; ob.DateTime = DateTime.Now; if (tariffPlanViewModel.DiscWillEnd == null) { ob.DiscWillEnd = DateTime.Now; } else { ob.DiscWillEnd = (DateTime)tariffPlanViewModel.DiscWillEnd; } ob.Types = new List <TariffType>(); for (int i = 0; i < Types.Length; i++) { ob.Types.Add(data.TariffTypeRepos.GetById(Types[i])); } double fullPrice = 0; foreach (var type in ob.Types) { fullPrice += type.DiscountPrice; } if (ob.Types.Count > 1) { if (ob.Types.Count == 2) { ob.Price = (fullPrice / 100) * 90; } else { ob.Price = (fullPrice / 100) * 85; } } else { ob.Price = Math.Round(fullPrice, 1); } data.TariffPlanRepos.Update(ob); data.Commit(); return(RedirectToAction("TariffPlans", "Admin")); } ViewBag.TariffTypes = data.TariffTypeRepos.GetAll(); ViewBag.Id = id; ViewBag.PlanTypes = data.TariffPlanRepos.GetById((int)id).Types; return(View(tariffPlanViewModel)); } catch (Exception) { return(HttpNotFound()); } }
public Abonent(Port port, TariffPlan plan, Terminal terminal) { this.Port = port; this.TariffPlan = plan; this.Terminal = terminal; }
public Entry(Port port, Subscriber subscriber, TariffPlan tariffPlan) { Port = port ?? throw new ArgumentNullException(nameof(port)); Subscriber = subscriber ?? throw new ArgumentNullException(nameof(subscriber)); TariffPlan = tariffPlan ?? throw new ArgumentNullException(nameof(tariffPlan)); }