public JsonResult Update([FromBody] ClientDetailsViewModel data) { if (data != null) { data.Utilizador_Alteracao_eSUCH = User.Identity.Name; var updateClientTask = WSCustomerService.UpdateAsync(data, _configws); try { updateClientTask.Wait(); } catch (Exception ex) { data.eReasonCode = 3; data.eMessage = "Ocorreu um erro ao atualizar o cliente no NAV."; data.eMessages.Add(new TraceInformation(TraceType.Error, ex.Message)); return(Json(data)); } var result = updateClientTask.Result; if (result == null) { data.eReasonCode = 3; data.eMessage = "Ocorreu um erro ao atualizar o cliente no NAV."; return(Json(data)); } var client = WSCustomerService.MapCustomerNAVToCustomerModel(result.WSCustomer); if (client != null) { client.eReasonCode = 1; return(Json(client)); } } return(Json(false)); }
public JsonResult Delete([FromBody] ClientDetailsViewModel data) { if (data != null && data.No != null) { var deleteClientTask = WSCustomerService.DeleteAsync(data.No, _configws); try { deleteClientTask.Wait(); } catch (Exception ex) { data.eReasonCode = 3; data.eMessage = "Ocorreu um erro a apagar o cliente no NAV."; data.eMessages.Add(new TraceInformation(TraceType.Error, ex.Message)); return(Json(data)); } var result = deleteClientTask.Result; if (result != null) { return(Json(new ErrorHandler() { eReasonCode = 0, eMessage = "Projeto removido com sucesso." })); } } return(Json(false)); }
public JsonResult GetDetails([FromBody] ClientDetailsViewModel data) { if (data != null && data.No != null) { var getClientTask = WSCustomerService.GetByNoAsync(data.No, _configws); try { getClientTask.Wait(); } catch (Exception ex) { data.eReasonCode = 3; data.eMessage = "Ocorreu um erro a obter o cliente no NAV."; data.eMessages.Add(new TraceInformation(TraceType.Error, ex.Message)); return(Json(data)); } ClientDetailsViewModel client = getClientTask.Result; if (client != null) { return(Json(client)); } } return(Json(false)); }