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());
                    }
                }
            }
        }
Пример #2
0
        public async Task <LineDto> CreateLine(LineDto lineDto, SelectedNumberDto selectedNumberDto)
        {
            using (CellularCompanyContext db = new CellularCompanyContext())
            {
                try
                {
                    if (lineDto == null)
                    {
                        return(null);
                    }
                    else
                    {
                        lineDto.SelectedNumbers = selectedNumberDto;
                        db.Lines.Add(lineDto.ToModel());
                        await db.SaveChangesAsync();

                        return(lineDto);
                    }
                }
                catch (Exception ex)
                {
                    Debug.WriteLine(ex.Message);
                    return(null);
                }
            }
        }
Пример #3
0
        public async Task <LineDto> AddLine(LineDto newLine, SelectedNumberDto newSelectedNumber)
        {
            Task <LineDto> lineDto;

            lock (_obj)
            {
                lineDto = _lineProvider.AddLine(newLine, newSelectedNumber);
            }
            return(await lineDto);
        }
Пример #4
0
 public static SelectedNumbers ToModel(this SelectedNumberDto selectedNumberDto)
 {
     if (selectedNumberDto == null)
     {
         return(null);
     }
     return(new SelectedNumbers
     {
         SelectedNumberId = selectedNumberDto.SelectedNumberId,
         FirstNumber = selectedNumberDto.FirstNumber,
         SecondNumber = selectedNumberDto.SecondNumber,
         ThirdNumber = selectedNumberDto.ThirdNumber,
         Line = selectedNumberDto.Line.ToModel()
     });
 }
        public async Task <SelectedNumberDto> CreateSelectedNumber(SelectedNumberDto selectedNumberDto)
        {
            using (CellularCompanyContext db = new CellularCompanyContext())
            {
                if (selectedNumberDto == null)
                {
                    return(null);
                }
                else
                {
                    db.SelectedNumbers.Add(selectedNumberDto.ToModel());
                    await db.SaveChangesAsync();

                    return(selectedNumberDto);
                }
            }
        }
Пример #6
0
 //ctor
 public LineViewModel(INavigationService navigationService)
 {
     try
     {
         _navigationService = navigationService;
         SelectedLine       = new LineDto();
         Line            = new LineDto();
         PackageIncludes = new PackageIncludeDto();
         SelectedNumbers = new SelectedNumberDto();
         Lines           = new CustomObservableCollection <LineDto>();
         InitializeObservableCollections();
         InitializeCommands();
     }
     catch (Exception ex)
     {
         Debug.WriteLine(ex.Message);
     }
 }
 public async Task <bool> AddFullLine(LineDto line, PackageIncludeDto packageInclude, SelectedNumberDto selectedNumber, CustomerDto customer)
 {
     return(await _CRMProvider.AddFullLine(line, packageInclude, selectedNumber, customer));
 }
 public async Task <LineDto> AddLine(LineDto lineDto, SelectedNumberDto selectedNumberDto)
 {
     return(await GetContainer().Resolve <ILineRepository>().CreateLine(lineDto, selectedNumberDto));
 }
Пример #9
0
 public async Task <SelectedNumberDto> UpdateSelectedNumber(int id, SelectedNumberDto selectedNumberDto)
 {
     return(await GetContainer().Resolve <ISelectedNumberRepository>().UpdateSelectedNumber(id, selectedNumberDto));
 }
Пример #10
0
 public async Task <SelectedNumberDto> AddSelectedNumber(SelectedNumberDto selectedNumberDto)
 {
     return(await GetContainer().Resolve <ISelectedNumberRepository>().CreateSelectedNumber(selectedNumberDto));
 }