// GET: Lookups public ActionResult Index() { LookupsViewModel model = new LookupsViewModel() { Language = new Language(), Department = new Department() }; return(View(model)); }
public async Task <IActionResult> Update([FromBody] LookupsViewModel lvm) { try { return(Ok(await lookupRepo.SaveOrUpdate(lvm))); } 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] LookupsViewModel lvm) { try { CurrentUser cUser = new CurrentUser(HttpContext, _configuration); lvm.UserId = cUser.UserId; lvm.LookupId = 0; lvm.Active = "Y"; return(Ok(await lookupRepo.SaveOrUpdate(lvm))); } 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 <IEnumerable <dynamic> > SaveOrUpdate([FromBody] LookupsViewModel lvm) { string sql = "dbo.EAppSaveLookups"; using (var conn = util.MasterCon()) { try { string LookupName = lvm.Lname; string LookupValue = lvm.Lvalue; return(await(conn.QueryAsync <dynamic>(sql, new { lvm.LookupId, lvm.LanguageId, lvm.LookupCode, LookupName, LookupValue, lvm.ListOrder, lvm.Descriptions, lvm.Active, lvm.UserId }, commandType: CommandType.StoredProcedure))); } catch (SqlException sqlException) { if (sqlException.Number == 2601 || sqlException.Number == 2627) { throw new CustomException("Duplicate", "Lookup Code already Exists.", "Error", true, sqlException); } else { throw new CustomException("Due to some Technical Reason, Unable to Save or Update", "Error", true, sqlException); } } catch (Exception ex) { throw new CustomException("Unable to Save Or Update, Please Contact Support!!!", "Error", true, ex); } } }