コード例 #1
0
        public PartialViewResult _Categories()
        {
            var userData = MvcApplication.GetUserData(User.Identity.Name);

            if (userData == null || userData.UserId < 1)
            {
                return(PartialView(new List <ExpenseCategoryObj>()));
            }

            var searchObj = new ExpenseCategorySearchObj
            {
                AdminUserId       = userData.UserId,
                Status            = -2,
                ExpenseCategoryId = 0
            };

            var retVal = ExpenseLookUpServices.LoadExpenseCategories(searchObj, userData.Username);

            if (retVal?.Status == null)
            {
                return(PartialView(new List <ExpenseCategoryObj>()));
            }

            if (!retVal.Status.IsSuccessful)
            {
                return(PartialView(new List <ExpenseCategoryObj>()));
            }

            if (!retVal.ExpenseCategories.Any())
            {
                return(PartialView(new List <ExpenseCategoryObj>()));
            }

            var categories = retVal.ExpenseCategories.Where(c => c.Status == 1).OrderBy(c => c.ExpenseCategoryId);

            return(PartialView(categories));
        }
コード例 #2
0
        public ActionResult Index(int?clientId, int?productId)
        {
            try
            {
                ViewBag.Error = "";

                #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;

                #endregion

                #region Current User Session Check
                var userData = MvcApplication.GetUserData(User.Identity.Name);
                if (userData == null || userData.UserId < 1)
                {
                    ViewBag.Error = "Session Has Expired! Please Re-Login";
                    return(View(new List <ExpenseItemSettingObj>()));
                }

                #endregion

                #region Other Objects Names
                var categorySearchObj = new ExpenseCategorySearchObj
                {
                    AdminUserId       = userData.UserId,
                    ExpenseCategoryId = 0,
                    Status            = 1
                };

                var classificationSearchObj = new ExpenseClassificationSearchObj()
                {
                    AdminUserId             = userData.UserId,
                    ExpenseClassificationId = 0,
                    Status = 1
                };


                var typeSearchObj = new ExpenseTypeSearchObj()
                {
                    AdminUserId   = userData.UserId,
                    ExpenseTypeId = 0,
                    Status        = 1
                };
                var itemSearchObj = new ExpenseItemSearchObj()
                {
                    AdminUserId   = userData.UserId,
                    ExpenseItemId = 0,
                    Status        = 1
                };


                #endregion

                #region Client Expense Item And Dependent Objects Session Check


                if (Session["_ExpenseItemSettingList_"] is List <ExpenseItemSettingObj> ExpenseItemSetting && ExpenseItemSetting.Any())
                {
                    if (Session["_Category_"] is List <ExpenseCategoryObj> expenseCategorys && !expenseCategorys.Any())
                    {
                        Session["_Category_"] = new List <ExpenseCategoryObj>();
                    }
                    if (Session["_Classification_"] is List <ExpenseClassificationObj> expenseClassifications && !expenseClassifications.Any())
                    {
                        Session["_Classification_"] = new List <ExpenseCategoryObj>();
                    }
                    if (Session["_Types_"] is List <ExpenseTypeObj> expenseType && !expenseType.Any())
                    {
                        Session["_Types_"] = new List <ExpenseCategoryObj>();
                    }
                    if (Session["_Items_"] is List <ExpenseItemObj> expenseItem && !expenseItem.Any())
                    {
                        Session["_Items_"] = new List <ExpenseItemObj>();
                    }
                    var clientExpenseItemList = ExpenseItemSetting.Where(m => m.ClientId == ClientId && m.ProductId == ProductId).ToList();
                    return(View(clientExpenseItemList));
                }

                #endregion

                #region Request and response Validations

                var searchObj = new ExpenseItemSettingSearchObj
                {
                    AdminUserId          = userData.UserId,
                    ExpenseItemSettingId = 0,
                    Status = 1
                };
                var retVal = ExpenseItemSettingServices.LoadExpenseItemSettings(searchObj, userData.Username);
                if (retVal?.Status == null)
                {
                    ViewBag.Error = " ExpenseItemSetting list is empty!";
                    return(View(new List <ExpenseItemSettingObj>()));
                }

                if (!retVal.Status.IsSuccessful)
                {
                    ViewBag.Error = string.IsNullOrEmpty(retVal.Status.Message.FriendlyMessage)
                        ? " ExpenseItemSetting list is empty!"
                        : retVal.Status.Message.FriendlyMessage;
                    return(View(new List <ExpenseItemSettingObj>()));
                }
                if (retVal.ExpenseItemSettings == null || !retVal.ExpenseItemSettings.Any())
                {
                    ViewBag.Error = " ExpenseItemSetting list is empty!";
                    return(View(new List <ExpenseItemSettingObj>()));
                }

                #endregion

                #region Initialize object Lists to sessions


                var categoryRetVal = ExpenseLookUpServices.LoadExpenseCategories(categorySearchObj, userData.Username);
                var catList        = categoryRetVal.ExpenseCategories.OrderBy(m => m.ExpenseCategoryId).ToList();
                Session["_Category_"] = catList;

                var classificationRetVal = ExpenseLookUpServices.LoadClassifications(classificationSearchObj, userData.Username);
                var classificationList   = classificationRetVal.ExpenseClassifications.OrderBy(m => m.ExpenseClassificationId).ToList();
                Session["_Classification_"] = classificationList;

                var typeRetVal = ExpenseLookUpServices.LoadExpenseTypes(typeSearchObj, userData.Username);
                var typeList   = typeRetVal.ExpenseTypes.OrderBy(m => m.ExpenseTypeId).ToList();
                Session["_Types_"] = typeList;

                var itemRetVal = ExpenseLookUpServices.LoadExpenseItems(itemSearchObj, userData.Username);
                var itemList   = itemRetVal.ExpenseItems.OrderBy(m => m.ExpenseItemId).ToList();
                Session["_Items_"] = itemList;

                var ExpenseItemSettings = retVal.ExpenseItemSettings.OrderBy(m => m.ExpenseItemSettingId).ToList();
                Session["_ExpenseItemSettingList_"] = ExpenseItemSettings.Where(m =>
                                                                                m.ClientId == ClientId && m.ProductId == ProductId).ToList();


                #endregion

                var clientProdExpItemList = ExpenseItemSettings.Where(m =>
                                                                      m.ClientId == ClientId && m.ProductId == ProductId).ToList();

                return(View(clientProdExpItemList));
            }
            catch (Exception ex)
            {
                ViewBag.Error = ex.Message;
                UtilTools.LogE(ex.StackTrace, ex.Source, ex.Message);
                return(View(new List <ExpenseItemSettingObj>()));
            }
        }
コード例 #3
0
        public ActionResult Index(int?clientId, int?productId)
        {
            try
            {
                ViewBag.Error = "";

                #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;

                #endregion

                #region Current User Session Check

                var userData = MvcApplication.GetUserData(User.Identity.Name);
                if (userData == null || userData.UserId < 1)
                {
                    ViewBag.Error = "Session Has Expired! Please Re-Login";
                    return(View(new List <DepartmentUserObj>()));
                }

                #endregion

                #region Check if Department User Session is null esle return to list

                if (Session["_DepartmentUserList_"] is List <DepartmentUserObj> DepartmentUser && DepartmentUser.Any())
                {
                    if (Session["_DepartmentList_"] is List <DepartmentObj> DepartmentList)
                    {
                        Session["_DepartmentList_"] = DepartmentList;
                    }
                    if (Session["_UsersList_"] is List <UserItemObj> UserList)
                    {
                        Session["_UsersList_"] = UserList;
                    }
                    var depList = DepartmentUser.Where(m => m.ClientId == ClientId && m.ProductId == ProductId).ToList();
                    return(View(depList));
                }

                #endregion

                #region Request Response and Validation of responses

                var searchObj2 = new UserSearchObj
                {
                    AdminUserId = userData.UserId,
                    Status      = -1000,
                    StopDate    = "",
                    StartDate   = "",
                    UserId      = 0,
                };
                var retValForUsers = new PortalUserManager().LoadUsers(searchObj2, userData.Username);

                if (retValForUsers?.Status == null)
                {
                    ViewBag.Error = "Error Occurred!";
                    return(View(new List <DepartmentUserObj>()));
                }

                if (retValForUsers.Users == null || !retValForUsers.Users.Any())
                {
                    ViewBag.Error = "Error Occurred!";
                    return(View(new List <DepartmentUserObj>()));
                }

                var searchObj3 = new DepartmentSearchObj
                {
                    AdminUserId  = userData.UserId,
                    DepartmentId = 0,
                    Status       = -1000,
                    StopDate     = "",
                    StartDate    = ""
                };
                var retValForDepartment = ExpenseLookUpServices.LoadDepartments(searchObj3, userData.Username);
                if (retValForDepartment?.Status == null)
                {
                    ViewBag.Error = "Error Occurred!";
                    return(View(new List <DepartmentUserObj>()));
                }

                if (retValForDepartment.Departments == null || !retValForDepartment.Departments.Any())
                {
                    ViewBag.Error = "Error Occurred!";
                    return(View(new List <DepartmentUserObj>()));
                }



                var searchObj = new DepartmentUserSearchObj
                {
                    AdminUserId      = userData.UserId,
                    DepartmentUserId = 0,
                };
                var retVal = DepartmentUserServices.LoadDepartmentUsers(searchObj, userData.Username);

                if (retVal?.Status == null)
                {
                    ViewBag.Error = " DepartmentUser list is empty!";
                    return(View(new List <DepartmentUserObj>()));
                }

                if (!retVal.Status.IsSuccessful)
                {
                    ViewBag.Error = string.IsNullOrEmpty(retVal.Status.Message.FriendlyMessage)
                        ? "  DepartmentUser list is empty!"
                        : retVal.Status.Message.FriendlyMessage;
                    return(View(new List <DepartmentUserObj>()));
                }
                if (retVal.DepartmentUsers == null || !retVal.DepartmentUsers.Any())
                {
                    ViewBag.Error = " DepartmentUser list is empty!";
                    return(View(new List <DepartmentUserObj>()));
                }


                #endregion

                #region Initialization of Responses into Sessions

                var Users           = retValForUsers.Users.OrderBy(m => m.UserId).ToList();
                var Depts           = retValForDepartment.Departments.OrderBy(m => m.DepartmentId).ToList();
                var DepartmentUsers = retVal.DepartmentUsers.OrderBy(m => m.DepartmentUserId).Where(m => m.ClientId == ClientId &&
                                                                                                    m.ProductId == ProductId).ToList();



                Session["_DepartmentUserList_"] = DepartmentUsers;
                Session["_DepartmentList_"]     = Depts.ToList();

                Session["_UsersList_"] = Users.ToList();

                #endregion

                return(View(DepartmentUsers));
            }
            catch (Exception ex)
            {
                ViewBag.Error = ex.Message;
                UtilTools.LogE(ex.StackTrace, ex.Source, ex.Message);
                return(View(new List <DepartmentUserObj>()));
            }
        }
コード例 #4
0
        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()));
            }
        }
コード例 #5
0
        public JsonResult ProcessAddDepenDentLKPRequest(RegExpenseLookupObj model)
        {
            try
            {
                #region Current user Session check

                var userData = MvcApplication.GetUserData(User.Identity.Name) ?? new UserData();
                if (userData.UserId < 1)
                {
                    return(Json(new { IsSuccessful = false, Error = "Your session has expired", IsAuthenticated = false }));
                }


                #endregion

                #region model validations

                if (model == null)
                {
                    return(Json(new { IsSuccessful = false, Error = "Your session has expired", IsAuthenticated = false }));
                }

                if (model.ClientId < 1)
                {
                    return(Json(new { isauthenticated = true, issuccessful = false, isreload = false, error = "client required " }));
                }

                if (model.ProductItemId < 1)
                {
                    return(Json(new { isauthenticated = true, issuccessful = false, isreload = false, error = "Product Item required " }));
                }

                if (model.ProductId < 1)
                {
                    return(Json(new { isauthenticated = true, issuccessful = false, isreload = false, error = "Product required " }));
                }
                if (string.IsNullOrEmpty(model.InclusionList) || model.InclusionList.Length < 0)
                {
                    return(Json(new { IsAuthenticated = true, IsSuccessful = false, IsReload = false, Error = "No Item Selected" }));
                }

                if (string.IsNullOrEmpty(model.LookupName) || model.LookupName.Length < 2)
                {
                    return(Json(new { IsAuthenticated = true, IsSuccessful = false, IsReload = false, Error = "Lookup Name is required" }));
                }

                #endregion

                #region  Expense Lookup from service

                var searchObjLKP = new ExpenseLookupSearchObj
                {
                    AdminUserId     = userData.UserId,
                    ExpenseLookupId = 0,
                    Status          = -2
                };

                var retValLKP = ExpenseLookUpServices.LoadExpenseLookups(searchObjLKP, userData.Username);
                if (retValLKP?.Status == null && retValLKP.ExpenseLookups == null)
                {
                }

                var LKPList = retValLKP.ExpenseLookups
                              .Where(m => m.LookupName.Trim().ToLower().ToStandardHash()
                                     == model.LookupName.ToString().Trim().ToLower().ToStandardHash())
                              .OrderBy(m => m.ExpenseLookupId).ToList();

                if (LKPList == null || !LKPList.Any())
                {
                    return(Json(new { IsSuccessful = false, IsAuthenticated = true }));
                }

                var thisClientProdLKP = LKPList.SingleOrDefault(m => m.ClientId == model.ClientId && m.ProductId == model.ProductId);

                if (thisClientProdLKP == null || thisClientProdLKP.ExpenseLookupId < 1)
                {
                    return(Json(new { IsSuccessful = false, IsAuthenticated = true, Error = "Something went wrong" }));
                }

                thisClientProdLKP.InclusionList = thisClientProdLKP.InclusionList.TrimStart(',').TrimEnd(',');

                string[] NewLKPIdsArray;

                string[] addedLkpIds = thisClientProdLKP.InclusionList.Trim().Split(',');

                string[] modelLKPIds = model.InclusionList.Trim().Split(',');

                NewLKPIdsArray = addedLkpIds.Concat(modelLKPIds).ToArray();

                HashSet <string> newList = new HashSet <string>(NewLKPIdsArray);

                newList.UnionWith(addedLkpIds);
                string lkpIDtoAdd = string.Join(",", newList);



                #endregion

                #region Build Request Object

                var requestObj = new EditExpenseLookupObj
                {
                    ClientId            = model.ClientId,
                    ProductId           = model.ProductId,
                    AdminUserId         = userData.UserId,
                    ChannelCode         = thisClientProdLKP.ChannelCode,
                    ExclusionList       = " 10001,10001,10001,10001,10001,10001,10001,10001,10001,10001,10001,10001,10001,10001,10001,10001,10001,10001,10001,10001,10001,10001,10001,10001,10001,10001,10001,10001,10001,10001,10001,10001,10001,10001,10001,10001,10001,10001,10001,10001",
                    InclusionList       = lkpIDtoAdd,
                    IsEnabled           = thisClientProdLKP.IsEnabled,
                    LookupItem          = model.LookupItem,
                    LookupName          = model.LookupName,
                    RegisteredBy        = userData.UserId,
                    Status              = 1,
                    TimeStampRegistered = DateTime.Now.ToString("ddd-mmm-yyyy"),
                    ProductItemId       = thisClientProdLKP.ProductItemId,
                    ExpenseLookupId     = thisClientProdLKP.ExpenseLookupId,
                };

                #endregion

                #region Request and response validations

                var response = ExpenseLookUpServices.UpdateExpenseLookup(requestObj, userData.Username);
                if (response?.Status == null)
                {
                    return(Json(new { IsAuthenticated = true, IsSuccessful = false, IsReload = false, Error = "Error Occurred! Please try again later" }));
                }

                if (!response.Status.IsSuccessful)
                {
                    return(Json(new { IsAuthenticated = true, IsSuccessful = false, IsReload = false, Error = string.IsNullOrEmpty(response.Status.Message.TechnicalMessage) ? "Process Failed! Unable to add nomination Source" : response.Status.Message.TechnicalMessage }));
                }


                var searchObj = new ExpenseLookupSearchObj
                {
                    AdminUserId     = userData.UserId,
                    ExpenseLookupId = 0,
                    Status          = -2
                };

                var retVal = ExpenseLookUpServices.LoadExpenseLookups(searchObj, userData.Username);
                if (retVal?.Status != null && retVal.ExpenseLookups != null)
                {
                    var ExpenseLookups = retVal.ExpenseLookups.OrderBy(m => m.ExpenseLookupId).ToList();
                    Session["_ExpenseLookupList_"] = ExpenseLookups;
                }


                #endregion

                ViewBag.ClientId      = model.ClientId;
                ViewBag.ProductId     = model.ProductId;
                ViewBag.ProductItemId = model.ProductItemId;

                return(Json(new { IsAuthenticated = true, IsSuccessful = true, IsReload = false, Error = "" }));
            }
            catch (Exception ex)
            {
                UtilTools.LogE(ex.StackTrace, ex.Source, ex.Message);
                return(Json(new { IsAuthenticated = true, IsSuccessful = false, IsReload = false, Error = "Process Error Occurred! Please try again later" }));
            }
        }
コード例 #6
0
        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()));
            }
        }
コード例 #7
0
        public JsonResult ProcessEditExpenseLookupRequest(ExpenseLookupObj model)
        {
            try
            {
                #region Current User Session Check

                var userData = MvcApplication.GetUserData(User.Identity.Name) ?? new UserData();

                if (userData.UserId < 1)
                {
                    return(Json(new { IsSuccessful = false, Error = "Your session has expired", IsAuthenticated = false }));
                }

                #endregion

                #region Validation Checks
                var selExpenseLookup = Session["_CurrentSelExpenseLookup_"] as ExpenseLookupObj;
                if (selExpenseLookup == null || selExpenseLookup.ExpenseLookupId < 1)
                {
                    return(Json(new { IsSuccessful = false, Error = "Your session has expired", IsAuthenticated = false }));
                }

                if (model.ClientId < 1)
                {
                    return(Json(new { IsAuthenticated = true, IsSuccessful = false, IsReload = false, Error = "Client required " }));
                }
                if (model.ExpenseLookupId < 1)
                {
                    return(Json(new { IsAuthenticated = true, IsSuccessful = false, IsReload = false, Error = "ExpenseLookupId required" }));
                }

                if (string.IsNullOrEmpty(model.LookupName) || model.LookupName.Length < 2)
                {
                    return(Json(new { IsAuthenticated = true, IsSuccessful = false, IsReload = false, Error = "Lookup Name is required" }));
                }
                if (!GenericVal.Validate(model, out var msg))
                {
                    return(Json(new { IsAuthenticated = true, IsSuccessful = false, IsReload = false, Error = $"Validation Error Occurred! Detail: {msg}" }));
                }
                #endregion

                #region Build Requesr Object


                var passObj = new EditExpenseLookupObj()
                {
                    ClientId            = model.ClientId,
                    ProductId           = model.ProductId,
                    AdminUserId         = userData.UserId,
                    ChannelCode         = "Channel",
                    ExclusionList       = model.ExclusionList,
                    InclusionList       = model.InclusionList,
                    IsEnabled           = model.IsEnabled,
                    LookupItem          = model.LookupItem,
                    LookupName          = model.LookupName,
                    RegisteredBy        = 1,
                    Status              = 1,
                    TimeStampRegistered = DateTime.Now.ToString("ddd-mmm-yyyy"),
                    ExpenseLookupId     = model.ExpenseLookupId,
                    ProductItemId       = model.ProductItemId
                };


                #endregion

                #region Request and responses Validation checks

                var response = ExpenseLookUpServices.UpdateExpenseLookup(passObj, userData.Username);
                if (response?.Status == null)
                {
                    return(Json(new { IsAuthenticated = true, IsSuccessful = false, IsReload = false, Error = "Error Occurred! Please try again later" }));
                }

                if (!response.Status.IsSuccessful)
                {
                    return(Json(new { IsAuthenticated = true, IsSuccessful = false, IsReload = false, Error = string.IsNullOrEmpty(response.Status.Message.TechnicalMessage) ? "Process Failed! Unable to add course of study" : response.Status.Message.TechnicalMessage }));
                }

                Session["_CurrentSelExpenseLookup_"] = null;

                var searchObj = new ExpenseLookupSearchObj
                {
                    AdminUserId     = userData.UserId,
                    ExpenseLookupId = 0,
                    Status          = -2
                };

                var retVal = ExpenseLookUpServices.LoadExpenseLookups(searchObj, userData.Username);
                if (retVal?.Status != null && retVal.ExpenseLookups != null)
                {
                    var ExpenseLookups = retVal.ExpenseLookups.OrderBy(m => m.ExpenseLookupId).ToList();
                    Session["_ExpenseLookupList_"] = ExpenseLookups.Where(m => m.ProductId == model.ProductId && m.ClientId == model.ClientId && m.ProductItemId == model.ProductItemId).ToList();
                }

                #endregion

                return(Json(new { IsAuthenticated = true, IsSuccessful = true, IsReload = false, Error = "" }));
            }
            catch (Exception ex)
            {
                UtilTools.LogE(ex.StackTrace, ex.Source, ex.Message);
                return(Json(new { IsAuthenticated = true, IsSuccessful = false, IsReload = false, Error = "Process Error Occurred! Please try again later" }));
            }
        }
コード例 #8
0
        public JsonResult ProcessAddExpenseLookupRequest(ExpenseLookupObj model)
        {
            try
            {
                #region Current User Session Check

                var userData = MvcApplication.GetUserData(User.Identity.Name) ?? new UserData();
                if (userData.UserId < 1)
                {
                    return(Json(new { IsSuccessful = false, Error = "Your session has expired", IsAuthenticated = false }));
                }

                #endregion

                #region Model validations

                if (model == null)
                {
                    return(Json(new { IsSuccessful = false, Error = "Your session has expired", IsAuthenticated = false }));
                }

                if (model.ClientId < 1)
                {
                    return(Json(new { isauthenticated = true, issuccessful = false, isreload = false, error = "client required " }));
                }

                if (model.ProductItemId < 1)
                {
                    return(Json(new { isauthenticated = true, issuccessful = false, isreload = false, error = "Product Item required " }));
                }

                if (model.ProductId < 1)
                {
                    return(Json(new { isauthenticated = true, issuccessful = false, isreload = false, error = "Product required " }));
                }
                if (string.IsNullOrEmpty(model.InclusionList) || model.InclusionList.Length < 0)
                {
                    return(Json(new { IsAuthenticated = true, IsSuccessful = false, IsReload = false, Error = "No Item Selected" }));
                }

                if (string.IsNullOrEmpty(model.LookupName) || model.LookupName.Length < 2)
                {
                    return(Json(new { IsAuthenticated = true, IsSuccessful = false, IsReload = false, Error = "Lookup Name is required" }));
                }

                #endregion


                #region  Expense   Lookup from   service
                var searchObjLKP = new ExpenseLookupSearchObj
                {
                    AdminUserId     = userData.UserId,
                    ExpenseLookupId = 0,
                    Status          = -2
                };

                var retValLKP = ExpenseLookUpServices.LoadExpenseLookups(searchObjLKP, userData.Username);
                if (retValLKP?.Status == null && retValLKP.ExpenseLookups == null)
                {
                }

                var LKPList = retValLKP.ExpenseLookups
                              .Where(m => m.LookupName.Trim().ToLower().ToStandardHash()
                                     == model.LookupName.ToString().Trim().ToLower().ToStandardHash() &&
                                     m.ClientId == model.ClientId && m.ProductId == model.ProductId && m.ProductItemId == model.ProductItemId).ToList();

                if (LKPList.Count() != 0)
                {
                    return(Json(new { IsSuccessful = false, IsAuthenticated = true }));
                }


                #endregion


                #region Build Request Object

                ExpenseLookupRegRespObj response = null;
                var previousExpenseLookupList    = (List <ExpenseLookupObj>)Session["_ExpenseLookupList_"];

                var requestObjAdd = new RegExpenseLookupObj
                {
                    ClientId            = model.ClientId,
                    ProductId           = model.ProductId,
                    AdminUserId         = userData.UserId,
                    ChannelCode         = "Channel",
                    ExclusionList       = " 10001,10001,10001,10001,10001,10001,10001,10001,10001,10001,10001,10001,10001,10001,10001,10001,10001,10001,10001,10001,10001,10001,10001,10001,10001,10001,10001,10001,10001,10001,10001,10001,10001,10001,10001,10001,10001,10001,10001,10001",
                    InclusionList       = model.InclusionList,
                    IsEnabled           = model.IsEnabled,
                    LookupItem          = model.LookupItem,
                    LookupName          = model.LookupName,
                    RegisteredBy        = userData.UserId,
                    Status              = 1,
                    TimeStampRegistered = DateTime.Now.ToString("ddd-mmm-yyyy"),
                    ProductItemId       = model.ProductItemId,
                };
                response = ExpenseLookUpServices.AddExpenseLookup(requestObjAdd, userData.Username);


                #endregion

                #region Request Responses And Validations


                if (response?.Status == null)
                {
                    return(Json(new { IsAuthenticated = true, IsSuccessful = false, IsReload = false, Error = "Error Occurred! Please try again later" }));
                }

                if (!response.Status.IsSuccessful)
                {
                    return(Json(new { IsAuthenticated = true, IsSuccessful = false, IsReload = false, Error = string.IsNullOrEmpty(response.Status.Message.TechnicalMessage) ? "Process Failed! Unable to add nomination Source" : response.Status.Message.TechnicalMessage }));
                }


                var searchObj = new ExpenseLookupSearchObj
                {
                    AdminUserId     = userData.UserId,
                    ExpenseLookupId = 0,
                    Status          = -2
                };

                var retVal = ExpenseLookUpServices.LoadExpenseLookups(searchObj, userData.Username);
                if (retVal?.Status != null && retVal.ExpenseLookups != null)
                {
                    var ExpenseLookups = retVal.ExpenseLookups.OrderBy(m => m.ExpenseLookupId).ToList();
                    Session["_ExpenseLookupList_"] = ExpenseLookups.Where(m => m.ProductId == model.ProductId && m.ClientId == model.ClientId && m.ProductItemId == model.ProductItemId).ToList();
                }

                #endregion

                return(Json(new { IsAuthenticated = true, IsSuccessful = true, IsReload = false, Error = "" }));
            }
            catch (Exception ex)
            {
                UtilTools.LogE(ex.StackTrace, ex.Source, ex.Message);
                return(Json(new { IsAuthenticated = true, IsSuccessful = false, IsReload = false, Error = "Process Error Occurred! Please try again later" }));
            }
        }
コード例 #9
0
        public ActionResult Index(int?clientId, int?productId)
        {
            try
            {
                ViewBag.Error = "";
                #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;

                #endregion

                #region Current User Session Check

                var userData = MvcApplication.GetUserData(User.Identity.Name);
                if (userData == null || userData.UserId < 1)
                {
                    ViewBag.Error = "Session Has Expired! Please Re-Login";
                    return(View(new List <ExpenseLookupObj>()));
                }

                #endregion


                #region Check if session list is empty else return to view

                if (Session["_ExpenseLookupList_"] is List <ExpenseLookupObj> expenseLookup && expenseLookup.Any())
                {
                    var clientProd = expenseLookup.Where(m => m.ClientId == ClientId && m.ProductId == ProductId).ToList();
                    return(View(clientProd));
                }

                #endregion


                #region Request And Response Validations

                var searchObj = new ExpenseLookupSearchObj
                {
                    AdminUserId     = userData.UserId,
                    ExpenseLookupId = 0,
                    Status          = 1
                };
                var retVal = ExpenseLookUpServices.LoadExpenseLookups(searchObj, userData.Username);

                if (retVal?.Status == null)
                {
                    ViewBag.Error = " ExpenseLookup list is empty!";
                    return(View(new List <ExpenseLookupObj>()));
                }

                if (!retVal.Status.IsSuccessful)
                {
                    ViewBag.Error = string.IsNullOrEmpty(retVal.Status.Message.FriendlyMessage)
                        ? "  ExpenseLookup list is empty!"
                        : retVal.Status.Message.FriendlyMessage;
                    return(View(new List <ExpenseLookupObj>()));
                }
                if (retVal.ExpenseLookups == null || !retVal.ExpenseLookups.Any())
                {
                    ViewBag.Error = " ExpenseLookup list is empty!";
                    return(View(new List <ExpenseLookupObj>()));
                }

                #endregion

                #region List Initialization into Session
                var ExpenseLookups = retVal.ExpenseLookups.OrderBy(m => m.ExpenseLookupId).ToList();

                var ClientProdList = ExpenseLookups.Where(m => m.ClientId == ClientId && m.ProductId == ProductId).ToList();

                Session["_ExpenseLookupList_"] = ClientProdList;

                #endregion

                var clientProdExpLkps = ExpenseLookups.Where(m => m.ClientId == ClientId && m.ProductId == ProductId).ToList();

                return(View(clientProdExpLkps));
            }
            catch (Exception ex)
            {
                ViewBag.Error = ex.Message;
                UtilTools.LogE(ex.StackTrace, ex.Source, ex.Message);
                return(View(new List <ExpenseLookupObj>()));
            }
        }
コード例 #10
0
        public PartialViewResult RecommendationList(int ExpenseRequisitionId)
        {
            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(PartialView(new List <WorkflowDetailObj>()));
                }

                #endregion

                #region Id check
                if (ExpenseRequisitionId < 1)
                {
                    ViewBag.Error = "Invalid selection";
                    return(PartialView(new List <WorkflowDetailObj>()));
                }
                #endregion

                #region get approval work flow level name from session or service if session is empty

                if (Session["_ApprovalLevels_"] is List <WorkFlowApprovalLevelObj> WorkFlowApprovalLevelList && WorkFlowApprovalLevelList.Any())
                {
                    Session["_ApprovalLevels_"] = WorkFlowApprovalLevelList.ToList();
                }
                else
                {
                    var reqObjAppLvel = new WorkFlowApprovalLevelSearchObj
                    {
                        AdminUserId             = userData.UserId,
                        StartDate               = " ",
                        Status                  = -2,
                        StopDate                = "",
                        WorkFlowApprovalLevelId = 0,
                    };
                    var retValForAppLv = ExpenseLookUpServices.LoadWorkFlowApprovalLevels(reqObjAppLvel, userData.Username);
                    var appLevels      = retValForAppLv.WorkflowApprovalLevels.ToList();
                    Session["_ApprovalLevels_"] = appLevels;
                }

                #endregion

                #region return Approval levels comment if session is not null
                if (Session["_WorkflowComments_"] is List <WorkflowDetailObj> WorkflowDetailList && WorkflowDetailList.Any())
                {
                    return(PartialView(WorkflowDetailList.Where(m => m.ExpenseRequisitionId == ExpenseRequisitionId && m.Status != (int)WorkflowStatus.Processing).ToList()));
                }
                #endregion

                #region requests  for approval level comments and response  check
                var reqObj = new WorkflowDetailSearchObj
                {
                    AdminUserId      = userData.UserId,
                    StartDate        = " ",
                    Status           = -2,
                    StopDate         = "",
                    WorkflowDetailId = 0,
                };
                var retVal = WorkflowDetailServices.LoadWorkflowDetails(reqObj, userData.Username);

                var thisWorkflowComments = retVal.WorkflowDetails.Where(m => m.ExpenseRequisitionId == ExpenseRequisitionId && m.Status != (int)WorkflowStatus.Processing).ToList();
                if (thisWorkflowComments == null || !thisWorkflowComments.Any())
                {
                    ViewBag.Error = "Error Occurred! Unable to process selected item";
                    return(PartialView(new List <WorkflowDetailObj>()));
                }
                Session["_WorkflowComments_"] = thisWorkflowComments;

                #endregion

                return(PartialView(thisWorkflowComments));
            }
            catch (Exception ex)
            {
                ViewBag.Error = "Error Occurred! Please try again later";
                UtilTools.LogE(ex.StackTrace, ex.Source, ex.Message);
                return(PartialView(new List <WorkflowDetailObj>()));
            }
        }
コード例 #11
0
        public ActionResult GetRequisitions(int?clientId, int?productId, int?requestType, int?requestStatus, string start, string end, int?beneficiary, int?item, bool?printExcel)
        {
            try
            {
                #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;

                #endregion

                #region Current Session Check

                var userData = MvcApplication.GetUserData(User.Identity.Name);
                if (userData == null || userData.UserId < 1)
                {
                    ViewBag.Error = "Session Has Expired! Please Re-Login";
                    return(View(new List <ExpenseRequisitionObj>()));
                }


                #endregion

                DateTime dateTimeStart = Convert.ToDateTime(start);
                DateTime dateTimeEnd   = Convert.ToDateTime(end + " 23:59:59 PM");

                List <ExpenseRequisitionObj> filteredReqs = null;
                if (Session["_ExpenseRequisitionList_"] is List <ExpenseRequisitionObj> ExpenseRequisition && ExpenseRequisition.Any())
                {
                    #region check if department session is empty else get from service

                    if (Session["_DeptList_"] is List <DepartmentObj> DeptsList && DeptsList.Any())
                    {
                        Session["_DeptList_"] = DeptsList;
                    }
                    else
                    {
                        var searchObj3 = new DepartmentSearchObj
                        {
                            AdminUserId  = userData.UserId,
                            DepartmentId = 0,
                            Status       = -2,
                            StopDate     = "",
                            StartDate    = ""
                        };
                        var retValForDepartment = ExpenseLookUpServices.LoadDepartments(searchObj3, userData.Username);
                        var Depts = retValForDepartment.Departments.OrderBy(m => m.DepartmentId).ToList();
                        Session["_DeptList_"] = Depts;
                    }

                    #endregion

                    if (start != null && (start.Length > 0 || !string.IsNullOrEmpty(start) || start != "") || end != null && (end.Length > 0 || !string.IsNullOrEmpty(end) || end != ""))
                    {
                        var b = ExpenseRequisition.Select(m => Convert.ToDateTime(m.TimeStampRegistered.Replace('-', ' ').Trim()));

                        filteredReqs = ExpenseRequisition.Where(m =>
                                                                Convert.ToDateTime(m.TimeStampRegistered.Replace('-', ' ').Trim()) >= dateTimeStart &&
                                                                Convert.ToDateTime(m.TimeStampRegistered.Replace('-', ' ').Trim()) <= dateTimeEnd).ToList();
                        List <ExpenseRequisitionObj> filtReqs;

                        filtReqs = filteredReqs.Where(m => m.ClientId == ClientId && m.ProductId == ProductId).ToList();

                        ViewBag.BeneficiaryId = beneficiary;
                        ViewBag.ExpenseItemId = item;
                        ViewBag.GrandTotal    = ExpenseRequisition.Where(x => x.ClientId == ClientId && x.ProductId == ProductId).Sum(x => x.TotalAmount);

                        if (requestType != 0)
                        {
                            filteredReqs = filteredReqs.Where(m => m.RequestType == requestType).ToList();
                        }
                        if (requestStatus >= -100)
                        {
                            filteredReqs = filteredReqs.Where(m => m.Status == requestStatus).ToList();
                        }
                        if (beneficiary > 0 || item > 0)
                        {
                            var expenseItems = filteredReqs.SelectMany(m => m.ExpenseRequisitionItems).Where(x => x.ExpenseItemId == item && x.BeneficiaryId == beneficiary).ToList();

                            if (!expenseItems.Any())
                            {
                                return(View(new List <ExpenseRequisitionObj>()));
                            }
                            else
                            {
                                filtReqs = filteredReqs.Where(m => m.ExpenseRequisitionItems.FirstOrDefault().BeneficiaryId == expenseItems.FirstOrDefault().BeneficiaryId &&
                                                              m.ExpenseRequisitionItems.FirstOrDefault().ExpenseItemId == expenseItems.FirstOrDefault().ExpenseItemId).ToList();
                            }
                        }


                        if (printExcel ?? false)
                        {
                            return(GenerateExcel(filtReqs));
                        }
                        return(View(filtReqs));
                    }
                }

                #region request and response validations

                var searchObj = new ExpenseRequisitionSearchObj
                {
                    AdminUserId          = userData.UserId,
                    ExpenseRequisitionId = 0,
                    Status = requestStatus ?? -1000,
                };
                var retVal = ExpenseLookupServices.LoadExpenseRequisitions(searchObj, userData.Username);

                if (retVal?.Status == null)
                {
                    ViewBag.Error = " ExpenseRequisition list is empty!";
                    return(View(new List <ExpenseRequisitionObj>()));
                }

                if (!retVal.Status.IsSuccessful)
                {
                    ViewBag.Error = string.IsNullOrEmpty(retVal.Status.Message.FriendlyMessage)
                        ? "  ExpenseRequisition list is empty!"
                        : retVal.Status.Message.FriendlyMessage;
                    return(View(new List <ExpenseRequisitionObj>()));
                }
                if (retVal.ExpenseRequisitions == null || !retVal.ExpenseRequisitions.Any())
                {
                    ViewBag.Error = " ExpenseRequisition list is empty!";
                    return(View(new List <ExpenseRequisitionObj>()));
                }

                #endregion

                var ExpenseRequisitions = retVal.ExpenseRequisitions.OrderBy(m => m.ExpenseRequisitionId).ToList();//.Where(m => ).ToList();
                Session["_ExpenseRequisitionList_"] = ExpenseRequisitions.Where(m => m.ClientId == ClientId && m.ProductId == ProductId).ToList();
                return(View(new List <ExpenseRequisitionObj>()));
            }
            catch (Exception ex)
            {
                ViewBag.Error = ex.Message;
                UtilTools.LogE(ex.StackTrace, ex.Source, ex.Message);
                return(View(new List <ExpenseRequisitionObj>()));
            }
        }
コード例 #12
0
        public ActionResult GetDisbursements(int?clientId, int?productId, int?requestType, int?requestStatus, string start, string end)
        {
            try
            {
                #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;

                #endregion

                #region Current Session Check

                var userData = MvcApplication.GetUserData(User.Identity.Name);
                if (userData == null || userData.UserId < 1)
                {
                    ViewBag.Error = "Session Has Expired! Please Re-Login";
                    return(View(new List <DisbursementObj>()));
                }


                #endregion

                DateTime dateTimeStart = Convert.ToDateTime(start);
                DateTime dateTimeEnd   = Convert.ToDateTime(end + " 23:59:59 PM");

                List <DisbursementObj> disbursement = null;
                if (Session["_DisbursementList_"] is List <DisbursementObj> Disbursement && Disbursement.Any())
                {
                    #region check if department session is empty else get from service

                    if (Session["_DepartmentList_"] is List <DepartmentObj> DeptsList && DeptsList.Any())
                    {
                        Session["_DepartmentList_"] = DeptsList;
                    }
                    else
                    {
                        var searchObj3 = new DepartmentSearchObj
                        {
                            AdminUserId  = userData.UserId,
                            DepartmentId = 0,
                            Status       = -2,
                            StopDate     = "",
                            StartDate    = ""
                        };
                        var retValForDepartment = ExpenseLookUpServices.LoadDepartments(searchObj3, userData.Username);
                        var Depts = retValForDepartment.Departments.OrderBy(m => m.DepartmentId).ToList();
                        Session["_DepartmentList_"] = Depts;
                    }

                    #endregion

                    if (start != null && (start.Length > 0 || !string.IsNullOrEmpty(start) || start != "") || end != null && (end.Length > 0 || !string.IsNullOrEmpty(end) || end != ""))
                    {
                        disbursement = Disbursement.Where(m =>
                                                          Convert.ToDateTime(m.ApprovalDate.Replace('-', ' ').Trim()) >= dateTimeStart &&
                                                          Convert.ToDateTime(m.ApprovalDate.Replace('-', ' ').Trim()) <= dateTimeEnd).ToList();

                        if (requestType != 0)
                        {
                            disbursement = disbursement.Where(m => m.RequestType == requestType).ToList();
                        }
                        if (requestStatus >= -100)
                        {
                            disbursement = disbursement.Where(m => m.Status == requestStatus).ToList();
                        }

                        var disbursementList = disbursement.Where(m => m.ClientId == ClientId && m.ProductId == ProductId).ToList();
                        ViewBag.GrandTotal = Disbursement.Where(x => x.ClientId == ClientId && x.ProductId == ProductId).Sum(x => x.AmountDisbursed);
                        ViewBag.PageSum    = disbursementList.Sum(x => x.AmountDisbursed);
                        return(View(disbursementList));
                    }
                }

                #region request and response validations

                var searchObj = new DisbursementSearchObj
                {
                    AdminUserId    = userData.UserId,
                    DisbursementId = 0,
                    Status         = requestStatus ?? -1000,
                };
                var retVal = DisbursementServices.LoadDisbursements(searchObj, userData.Username);

                if (retVal?.Status == null)
                {
                    ViewBag.Error = " Disbursement list is empty!";
                    return(View(new List <DisbursementObj>()));
                }

                if (!retVal.Status.IsSuccessful)
                {
                    ViewBag.Error = string.IsNullOrEmpty(retVal.Status.Message.FriendlyMessage)
                        ? "  Disbursement list is empty!"
                        : retVal.Status.Message.FriendlyMessage;
                    return(View(new List <DisbursementObj>()));
                }
                if (retVal.Disbursements == null || !retVal.Disbursements.Any())
                {
                    ViewBag.Error = " Disbursement list is empty!";
                    return(View(new List <DisbursementObj>()));
                }

                #endregion

                var Disbursements = retVal.Disbursements.OrderBy(m => m.DisbursementId).ToList();//.Where(m => ).ToList();
                Session["_DisbursementList_"] = Disbursements.Where(m => m.ClientId == ClientId && m.ProductId == ProductId).ToList();
                return(View(new List <DisbursementObj>()));
            }
            catch (Exception ex)
            {
                ViewBag.Error = ex.Message;
                UtilTools.LogE(ex.StackTrace, ex.Source, ex.Message);
                return(View(new List <DisbursementObj>()));
            }
        }
コード例 #13
0
        public ActionResult RetirementModule(int?clientId, int?productId, int?productItemId)
        {
            try
            {
                #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 = productItemId ?? userClientSession.ProductItemId;

                #endregion

                #region Current user session check

                var userData = MvcApplication.GetUserData(User.Identity.Name);
                if (userData == null || userData.UserId < 1)
                {
                    ViewBag.Error = "Session Has Expired! Please Re-Login";
                    return(View(new List <DisbursementObj>()));
                }


                #endregion

                #region Check if list is null else return to view

                if (Session["_currentExpenseDisbursement_"] is List <DisbursementObj> DisbursementList && DisbursementList.Any())
                {
                    return(View(DisbursementList.Where(m => m.ClientId == ClientId && m.ProductId == ProductId).ToList()));
                }

                #endregion

                #region Request and Response Validations

                var searchObj = new DisbursementSearchObj
                {
                    AdminUserId    = userData.UserId,
                    DisbursementId = 0,
                    StartDate      = "",
                    Status         = (int)DisbursementStatus.Awaiting_Retirement,
                    StopDate       = "",
                    VoucheNumber   = ""
                };
                var retVal = DisbursementServices.LoadDisbursements(searchObj, userData.Username);
                if (retVal?.Status == null)
                {
                    return(View(new List <DisbursementObj>()));
                }

                if (retVal.Disbursements == null || !retVal.Disbursements.Any())
                {
                    ViewBag.Error = " DisbursementObj list is empty!";
                    return(View(new List <DisbursementObj>()));
                }

                #endregion

                #region Get Amount Approved for each Retired Expense into Session

                var searchObjExp = new ExpenseSearchObj
                {
                    AdminUserId = userData.UserId,
                    ExpenseId   = 0,
                    Status      = -1000,
                    StartDate   = " ",
                    StopDate    = " ",
                };
                var retValExp = ExpenseRequisitionServices.LoadExpenses(searchObjExp, userData.Username);
                if (retVal?.Status == null)
                {
                    ViewBag.Error = " Expense list is empty!";
                    return(View(new List <DisbursementObj>()));
                }

                if (retValExp.Expenses == null || !retValExp.Expenses.Any())
                {
                    return(View(new List <DisbursementObj>()));
                }
                var expenseList = retValExp.Expenses.ToList();

                Session["_ExpenseList_"] = expenseList;
                #endregion

                #region GET Item Names
                var itemSearchObj = new ExpenseItemSearchObj()
                {
                    AdminUserId   = userData.UserId,
                    ExpenseItemId = 0,
                    Status        = 1
                };


                var itemRetVal = ExpenseLookUpServices.LoadExpenseItems(itemSearchObj, userData.Username);
                if (itemRetVal?.Status == null)
                {
                    ViewBag.Error = "Error Occurred please try again later!";
                    return(View(new List <DisbursementObj>()));
                }
                var globalItemList = itemRetVal.ExpenseItems.OrderBy(m => m.ExpenseItemId).ToList();
                Session["_globalItems_"] = globalItemList;
                #endregion

                var clientProdExpenseDisbursement = retVal.Disbursements
                                                    .OrderBy(m => m.DisbursementId)
                                                    .Where(m => m.ClientId == ClientId && m.ProductId == ProductId)
                                                    .ToList();

                Session["_currentExpenseDisbursement_"] = clientProdExpenseDisbursement;


                return(View(clientProdExpenseDisbursement));
            }
            catch (Exception ex)
            {
                ViewBag.Error = ex.Message;
                UtilTools.LogE(ex.StackTrace, ex.Source, ex.Message);
                return(View(new List <DisbursementObj>()));
            }
        }
コード例 #14
0
        public ActionResult RetirementItems(int expenseRequisitionId)
        {
            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 List <ExpenseRequisitionObj>()));
                }

                #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      = userClientSession.ClientId;
                var ProductId     = userClientSession.ProductId;
                var ProductItemId = userClientSession.ProductItemId;

                #endregion

                #region Request to requisition endpoint to get it's Items

                if (expenseRequisitionId < 1)
                {
                    expenseRequisitionId = 0;
                    return(View(new List <ExpenseRequisitionObj>()));
                }

                var searchObj = new ExpenseRequisitionSearchObj
                {
                    AdminUserId          = userData.UserId,
                    ExpenseRequisitionId = 0,
                    Status = -1000
                };
                var retVal = ExpenseLookupServices.LoadExpenseRequisitions(searchObj, userData.Username);
                var ExpenseRequisitionList = retVal.ExpenseRequisitions.OrderBy(m => m.ExpenseRequisitionId).ToList();


                var expenseRequisitionItems = ExpenseRequisitionList.SingleOrDefault(m => m.ExpenseRequisitionId == expenseRequisitionId);
                if (expenseRequisitionItems == null || expenseRequisitionItems.ExpenseRequisitionId < 1)
                {
                    ViewBag.Error = "Error Occurred! Unable to process selected item";
                    return(View(new List <ExpenseRequisitionObj>()));
                }
                #endregion

                #region GET ITEM NAMES
                if (Session["_globalItems_"] is List <ExpenseItemObj> GlobItemlist && GlobItemlist.Any())
                {
                    Session["_globalItems_"] = GlobItemlist;
                }
                else
                {
                    var itemSearchObj = new ExpenseItemSearchObj
                    {
                        AdminUserId   = userData.UserId,
                        ExpenseItemId = 0,
                        Status        = -1000,
                        StartDate     = "",
                        StopDate      = "",
                    };


                    var itemRetVal = ExpenseLookUpServices.LoadExpenseItems(itemSearchObj, userData.Username);
                    if (itemRetVal?.Status == null)
                    {
                        ViewBag.Error = "Error Occurred please try again later!";
                        return(View(new List <ExpenseRequisitionObj>()));
                    }
                    var globalItemList = itemRetVal.ExpenseItems.ToList();
                    Session["_globalItems_"] = globalItemList;
                }

                #endregion

                #region Generate voucher nuber

                var voucherSouchObj = new VoucherNumberSearchObj
                {
                    AdminUserId = userData.UserId,
                    ClientId    = ClientId,
                    ProductId   = ProductId
                };
                ViewBag.VoucherNumber = VNServices.GenerateVoucherNumbers(voucherSouchObj).VoucherNumber;
                #endregion

                return(View(expenseRequisitionItems));
            }
            catch (Exception ex)
            {
                ViewBag.Error = "Error Occurred! Please try again later";
                UtilTools.LogE(ex.StackTrace, ex.Source, ex.Message);
                return(View(new RegExpenseRequisitionItemObj()));
            }
        }