public static ExpenseLookupRespObj LoadExpenseLookups(ExpenseLookupSearchObj regObj, string username) { var response = new ExpenseLookupRespObj { Status = new APIResponseStatus { IsSuccessful = false, Message = new APIResponseMessage(), }, }; try { var apiResponse = new APIHelper(APIEndpoints.LOAD_EXPENSES_LOOKUP_ENDPOINT, username, Method.POST).ProcessAPI <ExpenseLookupSearchObj, ExpenseLookupRespObj>(regObj, out var msg); if (msg.Code == 0 && string.IsNullOrEmpty(msg.TechMessage) && string.IsNullOrEmpty(msg.Message)) { return(apiResponse); } response.Status.Message.FriendlyMessage = msg.Message; response.Status.Message.TechnicalMessage = msg.TechMessage; return(response); } catch (Exception ex) { UtilTools.LogE(ex.StackTrace, ex.Source, ex.GetBaseException().Message); response.Status.Message.FriendlyMessage = "Error Occurred! Please try again later"; response.Status.Message.TechnicalMessage = "Error: " + ex.GetBaseException().Message; return(response); } }
public ActionResult AddItemLookup(int?categoryId, int?clientId, int?productId) { try { ViewBag.Error = ""; ViewBag.SessionError = ""; #region Curret User Session Check var userData = MvcApplication.GetUserData(User.Identity.Name) ?? new UserData(); if (userData.UserId < 1) { ViewBag.SessionError = "Your session has expired! Please re-login"; return(View(new ExpenseLookupObj())); } #endregion #region Client Product productItem Session Check var userClientSession = (AppSession)Session["_UserClientSession_"]; if (userClientSession == null || userClientSession.ClientId < 1 || userClientSession.ProductId < 1 || userClientSession.ProductItemId < 1) { return(RedirectToAction("Index", "Dashboard")); } var ClientId = clientId ?? userClientSession.ClientId; var ProductId = productId ?? userClientSession.ProductId; var ProductItemId = userClientSession.ProductItemId; ViewBag.ClientId = ClientId; ViewBag.ProductId = ProductId; ViewBag.ProductItemId = ProductItemId; #endregion #region Expense Item Lookup from Expense items service ExpenseLookupRespObj retVal = null; var searchObj = new ExpenseLookupSearchObj { AdminUserId = userData.UserId, ExpenseLookupId = 0, Status = -2 }; retVal = ExpenseLookUpServices.LoadExpenseLookups(searchObj, userData.Username); if (retVal?.Status == null && retVal.ExpenseLookups == null) { return(View(new ExpenseLookupObj())); } var itemsLKP = retVal.ExpenseLookups .Where(m => m.LookupName.Trim().ToLower().ToStandardHash() == ExpenseLookupItems.ExpenseItem.ToString().Trim().ToLower().ToStandardHash()) .OrderBy(m => m.ExpenseLookupId).ToList(); if (itemsLKP == null || !itemsLKP.Any()) { return(View(new ExpenseLookupObj())); } var clientProdItemsLKP = itemsLKP.SingleOrDefault(m => m.ClientId == clientId && m.ProductId == productId); if (clientProdItemsLKP == null || clientProdItemsLKP.ExpenseLookupId < 1) { return(View(new ExpenseLookupObj())); } Session["_clientProdCategoryLKP_"] = clientProdItemsLKP; string[] itemIds; itemIds = clientProdItemsLKP.InclusionList.Split(','); return(View(clientProdItemsLKP)); #endregion } catch (Exception ex) { ViewBag.Error = "Error Occurred! Please try again later"; UtilTools.LogE(ex.StackTrace, ex.Source, ex.Message); return(View(new RegExpenseLookupObj())); } }
public ActionResult AddClassificationLookup(int?categoryId, int?clientId, int?productId) { try { ViewBag.Error = ""; ViewBag.SessionError = ""; #region Current User Session Check var userData = MvcApplication.GetUserData(User.Identity.Name) ?? new UserData(); if (userData.UserId < 1) { ViewBag.SessionError = "Your session has expired! Please re-login"; return(View(new ExpenseLookupObj())); } #endregion #region Client Product productItem Session Check var userClientSession = (AppSession)Session["_UserClientSession_"]; if (userClientSession == null || userClientSession.ClientId < 1 || userClientSession.ProductId < 1 || userClientSession.ProductItemId < 1) { return(RedirectToAction("Index", "Dashboard")); } var ClientId = clientId ?? userClientSession.ClientId; var ProductId = productId ?? userClientSession.ProductId; var ProductItemId = userClientSession.ProductItemId; ViewBag.ClientId = ClientId; ViewBag.ProductId = ProductId; ViewBag.ProductItemId = ProductItemId; #endregion #region Fetch Client and Product Added Category var searchObjFiltered = new FilteredLookupSearchObj { AdminUserId = userData.UserId, ProductId = productId ?? 0, ClientId = clientId ?? 0, }; var retValForCat = ExpenseLookUpServices.LoadFilteredExpenseCategories(searchObjFiltered, userData.Username); var catList = retValForCat.ExpenseCategories.OrderBy(m => m.ExpenseCategoryId); ViewBag.CategoryList = catList; #endregion #region Check if List Session is null else return to view //if (!(Session["_ExpenseLookupList_"] is List<ExpenseLookupObj> ExpenseLookupList) || ExpenseLookupList.Count < 1) //{ // return View(new ExpenseLookupObj()); //} #endregion #region Expense Category Lookup from Category service or Session is not null ExpenseLookupRespObj retVal = null; //if (Session["_clientProdCategoryLKP_"] is ExpenseLookupObj ExpenseLookup) //{ // return View(ExpenseLookup); //} //else //{ var searchObj = new ExpenseLookupSearchObj { AdminUserId = userData.UserId, ExpenseLookupId = 0, Status = -2 }; retVal = ExpenseLookUpServices.LoadExpenseLookups(searchObj, userData.Username); if (retVal?.Status == null && retVal.ExpenseLookups == null) { return(View(new ExpenseLookupObj())); } //} var classificationLKP = retVal.ExpenseLookups .Where(m => m.LookupName.Trim().ToLower().ToStandardHash() == ExpenseLookupItems.ExpenseClassification.ToString().Trim().ToLower().ToStandardHash()) .OrderBy(m => m.ExpenseLookupId).ToList(); if (classificationLKP == null || !classificationLKP.Any()) { return(View(new ExpenseLookupObj())); } var clientProdClassificationLKP = classificationLKP.SingleOrDefault(m => m.ClientId == clientId && m.ProductId == productId); if (clientProdClassificationLKP == null || clientProdClassificationLKP.ExpenseLookupId < 1) { return(View(new ExpenseLookupObj())); } Session["_clientProdClassificationLKP_"] = clientProdClassificationLKP; string[] classificationIds; classificationIds = clientProdClassificationLKP.InclusionList.Split(','); return(View(clientProdClassificationLKP)); #endregion } catch (Exception ex) { ViewBag.Error = "Error Occurred! Please try again later"; UtilTools.LogE(ex.StackTrace, ex.Source, ex.Message); return(View(new RegExpenseLookupObj())); } }