public RequestStatusEnum UpdateLinePackage(LinePackObject linePackObj) { //updates the line,package,package details,and selected numbers lock (dbLock) { using (CnContextMock context = new CnContextMock()) { Package packpageFromDb = context.Packages.FirstOrDefault(p => p.ID == linePackObj.Package.ID); packpageFromDb.PackageTotalPrice = linePackObj.Package.PackageTotalPrice; packpageFromDb.PackageName = linePackObj.Package.PackageName; PackageDetails packdetFromDb = context.PackageDetails.FirstOrDefault(pd => pd.ID == linePackObj.PackageDetails.ID); packdetFromDb.DiscountPercentage = linePackObj.PackageDetails.DiscountPercentage; packdetFromDb.FixedCallPrice = linePackObj.PackageDetails.FixedCallPrice; packdetFromDb.FixedSmsPrice = linePackObj.PackageDetails.FixedSmsPrice; packdetFromDb.MaxMinutes = linePackObj.PackageDetails.MaxMinutes; packdetFromDb.MaxSMS = linePackObj.PackageDetails.MaxSMS; packdetFromDb.MostCalledNumber = linePackObj.PackageDetails.MostCalledNumber; SelectedNumbers selectedNumsFromDb = context.SelectedNumbers.FirstOrDefault(sn => sn.ID == linePackObj.SelectedNumbers.ID); selectedNumsFromDb.FirstNumber = linePackObj.SelectedNumbers.FirstNumber; selectedNumsFromDb.SecondNumber = linePackObj.SelectedNumbers.SecondNumber; selectedNumsFromDb.ThirdNumber = linePackObj.SelectedNumbers.ThirdNumber; context.SaveChanges(); } } LoadCollections(); return(RequestStatusEnum.Success); }
public IEnumerable <string> GetLineSelectedNumbers(int lineId) { using (CellularCompanyContext db = new CellularCompanyContext()) { try { List <string> list = new List <string>(); SelectedNumbers entity = db.SelectedNumbers.Where(s => s.Line.LineId == lineId).FirstOrDefault(); foreach (var propName in db.Entry(entity).CurrentValues.PropertyNames) { if (propName.EndsWith("Number")) { if (db.Entry(entity).Property(propName).CurrentValue != null) { list.Add(db.Entry(entity).Property(propName).CurrentValue.ToString()); } } } return(list); } catch (Exception ex) { Debug.WriteLine(ex.Message); return(null); } } }
public RequestStatusEnum CreateNewLinePackage(LinePackObject linePackObj) { //creates a new line,package,package details,and selected numbers lock (dbLock) { using (CnContextMock context = new CnContextMock()) { context.Packages.Add(new Package(linePackObj.Package.PackageName, linePackObj.Package.PackageTotalPrice)); context.SaveChanges(); LoadLinesAndPackges(); int PackageId = Packages.Last().ID; context.SelectedNumbers.Add(new SelectedNumbers(linePackObj.SelectedNumbers.FirstNumber, linePackObj.SelectedNumbers.SecondNumber, linePackObj.SelectedNumbers.ThirdNumber)); context.SaveChanges(); LoadLinesAndPackges(); int selectedNumId = SelectedNumbers.Last().ID; context.PackageDetails.Add(new PackageDetails(PackageId, "Custom Package", linePackObj.PackageDetails.MaxMinutes, 0, linePackObj.PackageDetails.MaxSMS, 0, linePackObj.PackageDetails.FixedSmsPrice, linePackObj.PackageDetails.FixedCallPrice, linePackObj.PackageDetails.DiscountPercentage, selectedNumId, linePackObj.PackageDetails.MostCalledNumber)); context.Lines.Add(new Line(linePackObj.ClientId, linePackObj.LineNumber, LineStatusEnum.Available, PackageId, linePackObj.EmployeeID)); context.SaveChanges(); } LoadCollections(); return(RequestStatusEnum.Success); } }
public async Task <SelectedNumberDto> UpdateSelectedNumber(int id, SelectedNumberDto selectedNumberDto) { using (CellularCompanyContext db = new CellularCompanyContext()) { if (id != selectedNumberDto.SelectedNumberId) { return(null); } else { var sn = db.SelectedNumbers.FirstOrDefault(s => s.SelectedNumberId == id); if (sn == null) { return(null); } else { SelectedNumbers selectedNumber = selectedNumberDto.ToModel(); db.Entry(selectedNumber).State = System.Data.Entity.EntityState.Modified; await db.SaveChangesAsync(); return(sn.ToDto()); } } } }
public AddEditLineViewModel(IHttpClient httpClient, IInputsValidator inputsValidator, ILogger logger) { this.httpClient = httpClient; this.inputsValidator = inputsValidator; this.logger = logger; InitCollections(); InitCommands(); SelectedNumbers = new SelectedNumbers(); }
public LinePackObject(string LineNumber, Package Package, PackageDetails PackageDetails, SelectedNumbers SelectedNumbers, string ClientId, int EmployeeID) { this.LineNumber = LineNumber; this.Package = Package; this.PackageDetails = PackageDetails; this.SelectedNumbers = SelectedNumbers; this.ClientId = ClientId; this.EmployeeID = EmployeeID; }
public void TestSendLinePackObj() { Package pack = linesManager.GetPackageByLineId("0523974471"); PackageDetails packDet = linesManager.GetPackageDetailsByPackageId(pack.ID); SelectedNumbers selectedNums = linesManager.GetSelectedNumbersById(packDet.SelectedNumbersID); LinePackObject linePackObj = new LinePackObject("0523974471", pack, packDet, selectedNums, "312149891", 1); Assert.AreEqual(RequestStatusEnum.Success, linesManager.SendLinePackageObj(linePackObj)); }
public List <SMS> GetSMSToContactsByDate(string lineNumber, YearAndMonth date) { //returns all the sms that a client made to his contacts in this month of the year Package package = GetPackageByLineId(lineNumber); PackageDetails packDet = GetPackageDetailsByPackageId(package.ID); SelectedNumbers selectedNums = GetSelectedNumbersById(packDet.SelectedNumbersID); return(SMS.Where(c => c.LineID == lineNumber && c.DestintationNumber == selectedNums.FirstNumber || c.DestintationNumber == selectedNums.SecondNumber || c.DestintationNumber == selectedNums.ThirdNumber || c.DestintationNumber == packDet.MostCalledNumber && c.DateOfSMS.Month == date.Month && c.DateOfSMS.Year == date.Year).ToList()); }
public async Task <SelectedNumberDto> GetSelectedNumber(int id) { using (CellularCompanyContext db = new CellularCompanyContext()) { SelectedNumbers selectedNumber = await db.SelectedNumbers.FindAsync(id); return(selectedNumber.ToDto()); } }
public List <Call> GetCallsNotToContactsByDate(string lineNumber, YearAndMonth date) { //returns all the calls that a client made to clients other than his contacts in this month of the year Package package = GetPackageByLineId(lineNumber); PackageDetails packDet = GetPackageDetailsByPackageId(package.ID); SelectedNumbers selectedNums = GetSelectedNumbersById(packDet.SelectedNumbersID); return(Calls.Where(c => c.LineID == lineNumber && c.DestinationNumber != selectedNums.FirstNumber && c.DestinationNumber != selectedNums.SecondNumber && c.DestinationNumber != selectedNums.ThirdNumber && c.DestinationNumber != packDet.MostCalledNumber && c.DateOfCall.Month == date.Month && c.DateOfCall.Year == date.Year).ToList()); }
internal static SelectedNumbersDb FromDTO(this SelectedNumbers selectedNumbers) { return(new SelectedNumbersDb { Id = selectedNumbers.Id, FirstNumber = selectedNumbers.FirstNumber, SecondNumber = selectedNumbers.SecondNumber, ThirdNumber = selectedNumbers.ThirdNumber, //PackageIncludesId = selectedNumbers.PackageIncludesId, //PackageIncludes = selectedNumbers.PackageIncludes.FromDTO() }); }
public static SelectedNumberDto ToDto(this SelectedNumbers selectedNumber) { if (selectedNumber == null) { return(null); } return(new SelectedNumberDto { SelectedNumberId = selectedNumber.SelectedNumberId, FirstNumber = selectedNumber.FirstNumber, SecondNumber = selectedNumber.SecondNumber, ThirdNumber = selectedNumber.ThirdNumber, Line = selectedNumber.Line.ToDto() }); }
public double GetPriceForPackageByLine(string lineNumber, Package package, YearAndMonth Date) { //gets the price for this line with this package Line line = networkRepository.GetLineById(lineNumber); Package packageForLine = networkRepository.GetPackageByLineId(line.Number); PackageDetails packDetForLine = networkRepository.GetPackageDetailsByPackageId(package.ID); SelectedNumbers selectedNums = networkRepository.GetSelectedNumbersById(packDetForLine.SelectedNumbersID); packDetForLine.UsedMinutes = GetMinutesThisMonth(lineNumber, Date); packDetForLine.UsedSMS = GetSmsThisMonth(lineNumber, Date); double MinutesToContacts = GetMinutesToContacts(lineNumber, Date); double SMSToContacts = GetSMSToContacts(lineNumber, Date); Receipt recepitForPackage = new Receipt(line.Number, package, packDetForLine, MinutesToContacts, SMSToContacts); return(recepitForPackage.TotalPayment); }
public async Task <IEnumerable <string> > GetSelectedNumberByLine(int lineId) { using (CellularCompanyContext db = new CellularCompanyContext()) { try { IEnumerable <string> selectedNumbers = new List <string>(); SelectedNumbers selectedNum = db.SelectedNumbers.FirstOrDefault(s => s.Line.LineId == lineId); var prop = db.Entry(selectedNum).CurrentValues.PropertyNames.Where(p => p.EndsWith("Number")); return(prop); } catch (Exception ex) { Debug.WriteLine(ex.Message); return(null); } } }
public Receipt GetRecipetByLineAndDate(string lineNumber, YearAndMonth Date) { //gets a recepit for this month of the year Line line = networkRepository.GetLineById(lineNumber); if (LineExistedAtDate(lineNumber, Date)) { Package package = networkRepository.GetPackageByLineId(line.Number); PackageDetails packDet = networkRepository.GetPackageDetailsByPackageId(package.ID); SelectedNumbers selectedNums = networkRepository.GetSelectedNumbersById(packDet.SelectedNumbersID); double MinutesToContacts = GetMinutesToContacts(lineNumber, Date); double SMSToContacts = GetSMSToContacts(lineNumber, Date); return(new Receipt(line.Number, package, packDet, MinutesToContacts, SMSToContacts)); } else { return(EmptyRecepit(lineNumber)); } }
public async Task <SelectedNumberDto> DeleteSelectedNumber(int id) { using (CellularCompanyContext db = new CellularCompanyContext()) { SelectedNumbers selectedNumber = await db.SelectedNumbers.FindAsync(id); if (selectedNumber == null) { return(null); } else { db.SelectedNumbers.Remove(selectedNumber); await db.SaveChangesAsync(); return(selectedNumber.ToDto()); } } }
public RequestStatusEnum DeleteLine(string line) { //deletes the line and all its belongings lock (dbLock) { using (CnContextMock context = new CnContextMock()) { Line lineFromDb = context.Lines.FirstOrDefault(l => l.Number == line); Package packageFromDb = context.Packages.FirstOrDefault(p => p.ID == lineFromDb.PackageID); PackageDetails packDetFromDb = context.PackageDetails.FirstOrDefault(pd => pd.PackageID == packageFromDb.ID); SelectedNumbers selectedNumsFromDb = context.SelectedNumbers.FirstOrDefault(sn => sn.ID == packDetFromDb.SelectedNumbersID); context.Lines.Remove(lineFromDb); context.Packages.Remove(packageFromDb); context.PackageDetails.Remove(packDetFromDb); context.SelectedNumbers.Remove(selectedNumsFromDb); context.SaveChanges(); LoadLinesAndPackges(); } return(RequestStatusEnum.Success); } }
public int AddSelectedNumbers(SelectedNumbers selectedNumbers) { return((int)PostAPIData <int?, SelectedNumbers>("addselectednumbers", selectedNumbers)); }
protected override void OnActivate() { subscription = Observable.Interval(TimeSpan.FromSeconds(3)) .Subscribe(_ => SelectedNumbers.Add(Constants.GetLipsum())); }
// Methods populating properties public void AddSelectedNumber(int number) { SelectedNumbers.Add(number); }
public SelectedNumbers GetSelectedNumbersById(int selectedNumbersId) { //returns the selected numbers that matches this idd return(SelectedNumbers.FirstOrDefault(sn => sn.ID == selectedNumbersId)); }