Example #1
0
        private bool UpdateClientDebt(ConstructionDTO construction)
        {
            ClientDTO client = Construction.Client;

            client.TotalDebt += construction.EndPrice;
            client.Constructions.Add(construction);
            return(ClientService.Build().UpdateWithChildren(client));
        }
Example #2
0
 private ConstructionDTO UpdateDtoFromEntries(ConstructionDTO dto)
 {
     dto.Client   = (ClientDTO)ClientsPicker.SelectedItem;
     dto.Title    = Title.Text;
     dto.Desc     = Desc.Text;
     dto.Cost     = double.Parse(Cost.Text);
     dto.EndPrice = double.Parse(EndPrice.Text);
     dto.Deadline = Deadline.Date;
     return(dto);
 }
Example #3
0
        private void ConstructionsListView_ItemSelected(object sender, SelectedItemChangedEventArgs e)
        {
            ConstructionDTO obj = (ConstructionDTO)ConstructionsListView.SelectedItem;

            ((ListView)sender).SelectedItem = null;
            if (obj != null)
            {
                Navigation.PushAsync(new ConstructionPage(obj.Id));
            }
        }
Example #4
0
        public ConstructionDTO ToDto(Construction entity)
        {
            ConstructionDTO dto = new ConstructionDTO()
            {
                Id       = entity.Id,
                Title    = entity.Title,
                Desc     = entity.Desc,
                Deadline = entity.Deadline,
                Cost     = entity.Cost,
                EndPrice = entity.EndPrice,
                Client   = entity.Client != null?ClientMapper.Build().ToDto(entity.Client) : new ClientDTO()
            };

            return(dto);
        }
Example #5
0
        public Construction ToEntity(ConstructionDTO dto)
        {
            Construction Construction = new Construction()
            {
                Id       = dto.Id,
                Title    = dto.Title,
                Desc     = dto.Desc,
                Deadline = dto.Deadline,
                Cost     = dto.Cost,
                EndPrice = dto.EndPrice,
                Client   = dto.Client != null?ClientMapper.Build().ToEntity(dto.Client) : new Client()
            };

            return(Construction);
        }
Example #6
0
        public ConstructionDTO ToDtoWithChildren(Construction entity)
        {
            ConstructionDTO dto = new ConstructionDTO()
            {
                Id                           = entity.Id,
                Title                        = entity.Title,
                Desc                         = entity.Desc,
                Deadline                     = entity.Deadline,
                Cost                         = entity.Cost,
                EndPrice                     = entity.EndPrice,
                Client                       = entity.Client != null?ClientMapper.Build().ToDto(entity.Client) : new ClientDTO(),
                                        Crew = entity.Crew != null?EmployeeMapper.Build().ToDtoList(entity.Crew).ToList() : new List <EmployeeDTO>()
            };

            return(dto);
        }
Example #7
0
        public Construction ToEntityWithChildren(ConstructionDTO dto)
        {
            Construction Construction = new Construction()
            {
                Id                           = dto.Id,
                Title                        = dto.Title,
                Desc                         = dto.Desc,
                Deadline                     = dto.Deadline,
                Cost                         = dto.Cost,
                EndPrice                     = dto.EndPrice,
                Client                       = dto.Client != null?ClientMapper.Build().ToEntity(dto.Client) : new Client(),
                                        Crew = dto.Crew != null?EmployeeMapper.Build().ToEntityList(dto.Crew).ToList() : new List <Employee>()
            };

            return(Construction);
        }
Example #8
0
 private async void CreateConstructionBtn_Clicked(object sender, EventArgs e)
 {
     try
     {
         ConstructionDTO constr = UpdateDtoFromEntries(Construction);
         constr.Id = ConstructionService.Build().Create(constr);
         if (UpdateClientDebt(constr))
         {
             await DisplayAlert("Sucesso!", "Construção atualizada!", "Ok");
         }
     }
     catch (Exception ex)
     {
         await DisplayAlert("ERRO!", "Aconteceu algo errado, detalhes: " + ex.Message, "Ok");
     }
 }
Example #9
0
        public async Task <bool> Update(ConstructionDTO construct)
        {
            if (construct == null || construct.Id <= 0)
            {
                return(false);
            }

            var result = await HttpClient.PostAsJsonAsync($"api/construction/update", construct);

            if (result.IsSuccessStatusCode)
            {
                return(true);
            }

            return(false);
        }
        public async Task <ActionResult> Update([FromBody] ConstructionDTO model)
        {
            var construction = _mapper.Map <ConstructionEntity>(model);

            using var transaction = await _context.Database.BeginTransactionAsync();

            List <BorderPointEntity> oldBorders =
                await _context.BorderPoints.Where(b => b.ConstructionId == model.Id).ToListAsync();

            _context.BorderPoints.RemoveRange(oldBorders);

            _context.Constructions.Update(construction);

            await _context.SaveChangesAsync();

            await transaction.CommitAsync();

            return(Ok());
        }
Example #11
0
 public bool Delete(ConstructionDTO entityDto)
 {
     return(ConstructionRepository.Build().Delete(ConstructionMapper.Build().ToEntity(entityDto)));
 }
Example #12
0
 public bool UpdateWithChildren(ConstructionDTO entityDto)
 {
     return(ConstructionRepository.Build().UpdateWithChildren(ConstructionMapper.Build().ToEntityWithChildren(entityDto)));
 }
Example #13
0
 public int Create(ConstructionDTO entityDto)
 {
     return(ConstructionRepository.Build().Create(ConstructionMapper.Build().ToEntity(entityDto)));
 }
Example #14
0
 private void SetEntriesFromDto(ConstructionDTO dto)
 {
 }
Example #15
0
 private void SetDto(ConstructionDTO dto)
 {
     Construction = dto;
 }