private bool UpdateClientDebt(ConstructionDTO construction) { ClientDTO client = Construction.Client; client.TotalDebt += construction.EndPrice; client.Constructions.Add(construction); return(ClientService.Build().UpdateWithChildren(client)); }
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); }
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)); } }
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); }
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); }
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); }
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); }
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"); } }
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()); }
public bool Delete(ConstructionDTO entityDto) { return(ConstructionRepository.Build().Delete(ConstructionMapper.Build().ToEntity(entityDto))); }
public bool UpdateWithChildren(ConstructionDTO entityDto) { return(ConstructionRepository.Build().UpdateWithChildren(ConstructionMapper.Build().ToEntityWithChildren(entityDto))); }
public int Create(ConstructionDTO entityDto) { return(ConstructionRepository.Build().Create(ConstructionMapper.Build().ToEntity(entityDto))); }
private void SetEntriesFromDto(ConstructionDTO dto) { }
private void SetDto(ConstructionDTO dto) { Construction = dto; }