public async Task <IEnumerable <dynamic> > SaveOrUpdate([FromBody] ClientSiteViewModel csvm) { string sql = "dbo.EAppSaveClientSite"; using (var conn = util.MasterCon()) { try { return(await(conn.QueryAsync <dynamic>(sql, new { csvm.ClientId, csvm.ClientSiteId, csvm.InternalRefId, csvm.IndustryId, csvm.CountryId, csvm.CostCentreId, csvm.LanguageId, csvm.SiteName, csvm.Address1, csvm.Address2, csvm.City, csvm.Statename, csvm.POBox, csvm.Zip, csvm.Phone, csvm.ClientSiteStatus, csvm.UserId, csvm.Email, csvm.Logo, csvm.SiebelId, csvm.ExcludeFromAnalytics }, commandType: CommandType.StoredProcedure))); } catch (SqlException sqlException) { try { CustomUtils.HandleException(sqlException); return(null); // Returned Just to solve compile issue. } catch (CustomException cex) { throw new CustomException(cex.Message, cex.Type, cex.IsException, cex.Exception?.ToString()); } } catch (Exception ex) { throw new CustomException("Unable to Save Or Update, Please Contact Support!!!", "Error", true, ex); } } }
public async Task <IActionResult> Update([FromBody] ClientSiteViewModel csvm) { try { return(Ok(await clientSiteRepo.SaveOrUpdate(csvm))); } catch (CustomException cex) { var returnObj = new EmaintenanceMessage(cex.Message, cex.Type, cex.IsException, cex.Exception?.ToString()); return(StatusCode(StatusCodes.Status500InternalServerError, returnObj)); } catch (Exception ex) { return(StatusCode(StatusCodes.Status500InternalServerError, new EmaintenanceMessage(ex.Message))); } }
public async Task <IActionResult> Create([FromBody] ClientSiteViewModel csvm) { try { CurrentUser cUser = new CurrentUser(HttpContext, _configuration); csvm.UserId = cUser.UserId; csvm.ClientSiteId = 0; return(Ok(await clientSiteRepo.SaveOrUpdate(csvm))); } catch (CustomException cex) { var returnObj = new EmaintenanceMessage(cex.Message, cex.Type, cex.IsException, cex.Exception?.ToString()); return(StatusCode(StatusCodes.Status500InternalServerError, returnObj)); } catch (Exception ex) { return(StatusCode(StatusCodes.Status500InternalServerError, new EmaintenanceMessage(ex.Message))); } }