public JsonResult GetById([FromBody] ContactViewModel item) { ContactViewModel result = new ContactViewModel(); if (item != null && !string.IsNullOrEmpty(item.No)) { result = DBContacts.GetById(item.No).ParseToViewModel(); } if (!string.IsNullOrEmpty(result.NoCliente)) { NAVClientsViewModel cliente = DBNAV2017Clients.GetClientById(_config.NAVDatabaseName, _config.NAVCompanyName, result.NoCliente); if (cliente != null) { result.ClienteNome = cliente.Name; result.ClienteNIF = cliente.VATRegistrationNo_; result.ClienteEndereco = cliente.Address; result.ClienteCodigoPostal = cliente.PostCode; result.ClienteCidade = cliente.City; result.ClienteRegiao = cliente.RegionCode; result.ClienteTelefone = cliente.PhoneNo; result.ClienteEmail = cliente.EMail; } } return(Json(result)); }
public JsonResult GetContatosByCliente([FromBody] ClientDetailsViewModel data) { List <ContactViewModel> result = new List <ContactViewModel>(); if (data != null && !string.IsNullOrEmpty(data.No)) { result = DBContacts.GetAll().Where(x => x.NoCliente == data.No).ToList().ParseToViewModel(); List <NAVClientsViewModel> AllClients = DBNAV2017Clients.GetClients(_config.NAVDatabaseName, _config.NAVCompanyName, ""); List <ContactosServicos> AllServicos = DBContactsServicos.GetAll(); List <ContactosFuncoes> AllFuncoes = DBContactsFuncoes.GetAll(); result.ForEach(CT => { NAVClientsViewModel cliente = AllClients.Where(x => x.No_ == CT.NoCliente).FirstOrDefault() != null ? AllClients.Where(x => x.No_ == CT.NoCliente).FirstOrDefault() : null; CT.ClienteNome = cliente != null ? cliente.Name : ""; CT.ClienteNIF = cliente != null ? cliente.VATRegistrationNo_ : ""; CT.ClienteEndereco = cliente != null ? cliente.Address : ""; CT.ClienteCodigoPostal = cliente != null ? cliente.PostCode : ""; CT.ClienteCidade = cliente != null ? cliente.City : ""; CT.ClienteRegiao = cliente != null ? cliente.RegionCode : ""; CT.ClienteTelefone = cliente != null ? cliente.PhoneNo : ""; CT.ClienteEmail = cliente != null ? cliente.EMail : ""; CT.ServicoNome = AllServicos.Where(x => x.ID == CT.NoServico).FirstOrDefault() != null ? AllServicos.Where(x => x.ID == CT.NoServico).FirstOrDefault().Servico : ""; CT.FuncaoNome = AllFuncoes.Where(x => x.ID == CT.NoFuncao).FirstOrDefault() != null ? AllFuncoes.Where(x => x.ID == CT.NoFuncao).FirstOrDefault().Funcao : ""; }); } return(Json(result.OrderByDescending(x => x.No))); }
public void SetDimensionsFor(AuthorizedProjectViewModel authProj, string projectRegion, NAVClientsViewModel customer) { if (this == null) { return; } if (customer != null && customer.InternalClient) { this.RegionCode = customer.RegionCode; this.FunctionalAreaCode = customer.FunctionalAreaCode; this.ResponsabilityCenterCode = customer.ResponsabilityCenterCode; } else if (authProj != null) { this.RegionCode = authProj.CodRegiao; this.FunctionalAreaCode = authProj.CodAreaFuncional; if (authProj.CodRegiao == projectRegion) { this.ResponsabilityCenterCode = authProj.CodCentroResponsabilidade; } } }