public async Task TestAplicaBonusDate() { Client client = new Client() { FirstName = "Octavian", LastName = "Pintiliciuc", CodNumericPersonal = "1960914080014" }; DateMobile[] date = { new DateMobile() { TipDate = "Retea", NumarDate = 100, } }; Abonament abonament = new Abonament() { Pret = 1000, DataInceput = DateTime.Now.AddDays(1), DataSfarsit = new DateTime(2020, 9, 14), NumeAbonament = "Abonament Digi", AbonamentDate = date }; Contract contract = new Contract() { Client = client, Valabil = true, Abonament = abonament, }; Bonus bonus = new Bonus() { MinuteBonus = 100, SmsBonus = 20, DateBonus = 10, Contract = contract, TipBonus = "Retea" }; this.contractRepository.Setup(t => t.Insert(It.IsAny <Contract>())); Contract result = await this.controller.AplicaBonus(bonus); Assert.AreEqual(110, result.Abonament.AbonamentDate.FirstOrDefault().NumarDate); }
public async Task <Abonament> ExecutaApel(ConvorbireTelefonica convorbireTelefonica, Contract contract) { await this.convorbireRepository.Insert(convorbireTelefonica); Client initiator = convorbireTelefonica.Initiator; Abonament abonament = initiator.Contracte.Where(con => con.Id == contract.Id).FirstOrDefault().Abonament; abonament.AbonamentMinute.Where(minute => minute.TipMinute == convorbireTelefonica.TipConvorbire).FirstOrDefault().MinuteConsumate += (int)convorbireTelefonica.DurataConvorbire; await this.abonamentRepository.Update(abonament); return(abonament); }
// GET: Abonamente/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Abonament abonament = db.Abonamente.Find(id); if (abonament == null) { return(HttpNotFound()); } ViewBag.ClientID = new SelectList(db.Clienti, "ClientID", "NumeClient", abonament.ClientID); ViewBag.OfertaID = new SelectList(db.Oferte, "OfertaID", "NumeOferta", abonament.OfertaID); return(View(abonament)); }
public async Task <Abonament> PrelungireAbonament(Abonament abonament, DateTime dataExpirareNoua) { if (abonament == null) { throw new ArgumentException("Contractul este null"); } if (dataExpirareNoua < abonament.DataSfarsit) { throw new ArgumentException("Abonamentul nu se poate scurta"); } abonament.DataSfarsit = dataExpirareNoua; await this.UpdateAbonament(abonament); return(abonament); }
public async Task TestDeleteAbonamentObject() { Abonament abonament = new Abonament() { Pret = 1000, DataInceput = DateTime.Now.AddDays(1), DataSfarsit = new DateTime(2020, 9, 14), NumeAbonament = "Abonament Digi" }; Mock <IAbonamentRepository> repositoryMock = new Mock <IAbonamentRepository>(); AbonamentController abonamentController = new AbonamentController(repositoryMock.Object); repositoryMock.Setup(t => t.Delete(It.IsAny <Abonament>())).Verifiable(); await abonamentController.DeleteAbonament(abonament); repositoryMock.VerifyAll(); }
public async Task <IActionResult> Profile(UserViewModel model) { var basicAbonament = await _context.BasicAbonaments.FirstOrDefaultAsync(x => x.Name == model.NewAbonament.Name); Abonament abonament = new Abonament() { Name = basicAbonament.Name, AccessLimit = model.NewAbonament.AccessLimit, IsDeleted = basicAbonament.IsDeleted, StartDate = model.NewAbonament.StartDate, EndDate = model.NewAbonament.EndDate, CardId = model.Cards.Id, }; _context.Abonaments.Add(abonament); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Profile))); }
public void Post(AbonamentDTO value) { Abonament model = new Abonament() { tip = value.Tip, pret = value.Pret }; IAbonamentRepository.Create(model); for (int i = 0; i < value.ClinetId.Count; i++) { ClientAbonament ClientAbonament = new ClientAbonament() { abonamentId = model.abonamentId, Id = value.ClinetId[i] }; IClientAbonamentRepository.Create(ClientAbonament); } }
public async Task TestScurtareAbonament() { Mock <IAbonamentRepository> repositoryMock = new Mock <IAbonamentRepository>(); AbonamentController abonamentController = new AbonamentController(repositoryMock.Object); Abonament abonament = new Abonament() { Pret = 1000, DataInceput = DateTime.Now.AddDays(1), DataSfarsit = new DateTime(2020, 9, 14), NumeAbonament = "Abonament Digi" }; DateTime dataExpirate = new DateTime(2019, 10, 14); ArgumentException exception = await Assert.ThrowsExceptionAsync <ArgumentException>( () => abonamentController.PrelungireAbonament(abonament, dataExpirate)); Assert.AreEqual(exception.Message, "Abonamentul nu se poate scurta"); }
public async Task TestPrelungireAbonament() { Mock <IAbonamentRepository> repositoryMock = new Mock <IAbonamentRepository>(); AbonamentController abonamentController = new AbonamentController(repositoryMock.Object); Abonament abonament = new Abonament() { Pret = 1000, DataInceput = DateTime.Now.AddDays(1), DataSfarsit = new DateTime(2020, 9, 14), NumeAbonament = "Abonament Digi" }; DateTime dataExpirate = new DateTime(2020, 10, 14); repositoryMock.Setup(t => t.Update(It.IsAny <Abonament>())).Verifiable(); await abonamentController.PrelungireAbonament(abonament, dataExpirate); repositoryMock.VerifyAll(); }
public AbonamentDetailsDTO Get(int id) { Abonament Abonament = IAbonamentRepository.Get(id); AbonamentDetailsDTO MyAbonament = new AbonamentDetailsDTO() { Tip = Abonament.tip, Pret = Abonament.pret, }; IEnumerable <ClientAbonament> MyClientAbonaments = IClientAbonamentRepository.GetAll().Where(x => x.abonamentId == Abonament.abonamentId); if (MyClientAbonaments != null) { List <string> ClientNumeList = new List <string>(); foreach (ClientAbonament MyClientAbonament in MyClientAbonaments) { Client MyClient = IClientRepository.GetAll().SingleOrDefault(x => x.clientId == MyClientAbonament.clientId); ClientNumeList.Add(MyClient.nume); } MyAbonament.ClientNume = ClientNumeList; } return(MyAbonament); }
public Abonament Update(Abonament Abonament) { _context.Entry(Abonament).State = Microsoft.EntityFrameworkCore.EntityState.Modified; _context.SaveChanges(); return(Abonament); }
public async Task TestIncheieLuna3() { Client client = new Client() { FirstName = "Octavian", LastName = "Pintiliciuc", CodNumericPersonal = "1960914080014" }; Minute[] minute = { new Minute() { TipMinute = "Roaming", NumarMinute = 100, MinuteConsumate = 90, PretMinute = new Pret() { Suma = 3, Valuta = "RON" } } }; DateMobile[] date = { new DateMobile() { TipDate = "Roaming", NumarDate = 100, DateConsumate = 95, PretData = new Pret() { Suma = 1, Valuta = "RON" } } }; SMS[] sms = { new SMS() { TipSms = "Roaming", NumarSms = 5, SmsConsumate = 5, PretSms = new Pret() { Valuta = "RON", Suma = 2 } } }; Abonament abonament = new Abonament() { Pret = 1000, DataInceput = DateTime.Now.AddDays(1), DataSfarsit = new DateTime(2020, 9, 14), NumeAbonament = "Abonament Digi", AbonamentSms = sms, AbonamentDate = date, AbonamentMinute = minute }; Contract contract = new Contract() { Client = client, Valabil = true, Abonament = abonament, }; this.plataRepositoryMock.Setup(mock => mock.Update(It.IsAny <Plata>())); this.abonamentRepositoryMock.Setup(mock => mock.Update(It.IsAny <Abonament>())); Contract result = await this.controller.IncheieLunaSiReporteaza(contract); Assert.AreEqual(110, result.Abonament.AbonamentMinute.FirstOrDefault().NumarMinute); Assert.AreEqual(105, result.Abonament.AbonamentDate.FirstOrDefault().NumarDate); Assert.AreEqual(5, result.Abonament.AbonamentSms.FirstOrDefault().NumarSms); }
public void TestGetCost3() { Client client = new Client() { FirstName = "Octavian", LastName = "Pintiliciuc", CodNumericPersonal = "1960914080014" }; Minute[] minute = { new Minute() { TipMinute = "Roaming", NumarMinute = 100, PretMinute = new Pret() { Suma = 3, Valuta = "RON" } } }; DateMobile[] date = { new DateMobile() { TipDate = "Retea", NumarDate = 100, PretData = new Pret() { Suma = 1, Valuta = "RON" } } }; SMS[] sms = { new SMS() { TipSms = "Roaming", NumarSms = 5, PretSms = new Pret() { Valuta = "RON", Suma = 2 } } }; Abonament abonament = new Abonament() { Pret = 1000, DataInceput = DateTime.Now.AddDays(1), DataSfarsit = new DateTime(2020, 9, 14), NumeAbonament = "Abonament Digi", AbonamentSms = sms, AbonamentDate = date, AbonamentMinute = minute }; Contract contract = new Contract() { Client = client, Valabil = true, Abonament = abonament, }; double result = this.controller.GetCost(contract); Assert.AreEqual(1000, result); }
public Abonament Delete(int id) { Abonament abonament = IAbonamentRepository.Get(id); return(IAbonamentRepository.Delete(abonament)); }