Пример #1
0
        public ActionResult Add(long ADM_AccessGroupMasterId = 0, bool isActive = true)
        {
            try
            {
                long?TimeZone = currentUser.ADM_UserPreference.TimezoneLkup != null ? currentUser.ADM_UserPreference.TimezoneLkup : (long)DefaultTimeZone.CentralStandardTime;
                Session[ConstantTexts.AccessGroupSkillSessionKey]  = null;
                Session[ConstantTexts.AccessGroupReportSessionKey] = null;
                ViewBag.RoleList       = CacheUtility.GetAllLookupsFromCache((long)LookupTypes.Role);
                ViewBag.WorkBasketList = CacheUtility.GetAllLookupsFromCache((long)LookupTypes.WorkBasket);
                ViewBag.Reports        = ViewBag.Reports = CacheUtility.GetAllReportsFromCache(null, "");
                UIDOAccessGroup objUIDOAccessGroup = new UIDOAccessGroup();
                objUIDOAccessGroup.IsActive = true;
                objUIDOAccessGroup.lstDOADM_AccessGroupSkillsCorrelation = new List <DOADM_AccessGroupSkillsCorrelation>();
                objUIDOAccessGroup.lstDOADM_AccessGroupReportCorrelation = new List <DOADM_AccessGroupReportCorrelation>();

                if (ADM_AccessGroupMasterId != 0)
                {
                    DOADM_AccessGroupMaster objDOADM_AccessGroupMaster = new DOADM_AccessGroupMaster();
                    BLAccessGroup           objBLAccessGroup           = new BLAccessGroup();

                    objDOADM_AccessGroupMaster.ADM_AccessGroupMasterId = ADM_AccessGroupMasterId;
                    objDOADM_AccessGroupMaster.IsActive = isActive;
                    ExceptionTypes result = objBLAccessGroup.GetAccessGroupForEdit(objDOADM_AccessGroupMaster, out objUIDOAccessGroup);
                    Session[ConstantTexts.AccessGroupSkillSessionKey]  = objUIDOAccessGroup.lstDOADM_AccessGroupSkillsCorrelation;
                    Session[ConstantTexts.AccessGroupReportSessionKey] = objUIDOAccessGroup.lstDOADM_AccessGroupReportCorrelation;

                    DOADM_SkillsMaster        objDOADM_SkillsMaster = new DOADM_SkillsMaster();
                    List <DOADM_SkillsMaster> lstDOADM_SkillsMaster = new List <DOADM_SkillsMaster>();
                    BLSkills objBLSkills = new BLSkills();
                    objDOADM_SkillsMaster.IsActive       = true;
                    objDOADM_SkillsMaster.WorkBasketLkup = objUIDOAccessGroup.WorkBasketLkup;
                    objDOADM_SkillsMaster.RoleLkup       = objUIDOAccessGroup.RoleLkup;

                    ExceptionTypes result1 = objBLSkills.SearchSkills(TimeZone, objDOADM_SkillsMaster, out lstDOADM_SkillsMaster, out string errorMesssage);
                    ViewBag.Skills = lstDOADM_SkillsMaster.Where(x => x.IsActive == true).ToList();
                }
                return(View(objUIDOAccessGroup));
            }
            catch (Exception ex)
            {
                BLCommon.LogError(currentUser.ADM_UserMasterId, MethodBase.GetCurrentMethod().Name, (long)ErrorModuleName.ManageAccessGroups, (long)ExceptionTypes.Uncategorized, string.Empty, ex.ToString());
                return(RedirectToAction("Maintenance", "Error", new { Error = MethodBase.GetCurrentMethod().Name + " Action terminated and redirected to Maintenance. Error:" + ex.ToString() }));
            }
        }
Пример #2
0
        public ActionResult AddReportsToSession(DOADM_AccessGroupReportCorrelation objDOADM_AccessGroupReportCorrelation, long lPreviousReport = 0, int mode = 0)
        {
            long?TimeZone = currentUser.ADM_UserPreference.TimezoneLkup != null ? currentUser.ADM_UserPreference.TimezoneLkup : (long)DefaultTimeZone.CentralStandardTime;
            List <DOADM_AccessGroupReportCorrelation> lstDOADM_AccessGroupReportCorrelation = new List <DOADM_AccessGroupReportCorrelation>();

            try
            {
                if (Session[ConstantTexts.AccessGroupReportSessionKey] != null)
                {
                    lstDOADM_AccessGroupReportCorrelation = Session[ConstantTexts.AccessGroupReportSessionKey] as List <DOADM_AccessGroupReportCorrelation>;
                }
                switch (mode)
                {
                case 0:    //Add new Report to the list
                    if (lstDOADM_AccessGroupReportCorrelation.Where(xx => xx.RPT_ReportsMasterRef == objDOADM_AccessGroupReportCorrelation.RPT_ReportsMasterRef).Count() == 0)
                    {
                        objDOADM_AccessGroupReportCorrelation.IsActive          = true;
                        objDOADM_AccessGroupReportCorrelation.CreatedByRef      = currentUser.ADM_UserMasterId;
                        objDOADM_AccessGroupReportCorrelation.UTCCreatedOn      = ZoneLookupUI.ConvertToTimeZone(DateTime.UtcNow, TimeZone);
                        objDOADM_AccessGroupReportCorrelation.CreatedByName     = currentUser.FullName;
                        objDOADM_AccessGroupReportCorrelation.LastUpdatedByRef  = currentUser.ADM_UserMasterId;
                        objDOADM_AccessGroupReportCorrelation.UTCLastUpdatedOn  = ZoneLookupUI.ConvertToTimeZone(DateTime.UtcNow, TimeZone);
                        objDOADM_AccessGroupReportCorrelation.LastUpdatedByName = currentUser.FullName;
                        lstDOADM_AccessGroupReportCorrelation.Add(objDOADM_AccessGroupReportCorrelation);
                    }
                    else
                    {
                        objDOADM_AccessGroupReportCorrelation = lstDOADM_AccessGroupReportCorrelation.Where(xx => xx.RPT_ReportsMasterRef == objDOADM_AccessGroupReportCorrelation.RPT_ReportsMasterRef).FirstOrDefault();
                        objDOADM_AccessGroupReportCorrelation.LastUpdatedByRef  = currentUser.ADM_UserMasterId;
                        objDOADM_AccessGroupReportCorrelation.UTCLastUpdatedOn  = ZoneLookupUI.ConvertToTimeZone(DateTime.UtcNow, TimeZone);
                        objDOADM_AccessGroupReportCorrelation.LastUpdatedByName = currentUser.FullName;
                        objDOADM_AccessGroupReportCorrelation.IsActive          = true;
                    }
                    break;

                case 1:    //delete Report from added list
                    if (lstDOADM_AccessGroupReportCorrelation.Where(xx => xx.RPT_ReportsMasterRef == objDOADM_AccessGroupReportCorrelation.RPT_ReportsMasterRef).Count() > 0)
                    {
                        objDOADM_AccessGroupReportCorrelation = lstDOADM_AccessGroupReportCorrelation.Where(xx => xx.RPT_ReportsMasterRef == objDOADM_AccessGroupReportCorrelation.RPT_ReportsMasterRef).FirstOrDefault();
                        objDOADM_AccessGroupReportCorrelation.LastUpdatedByRef = currentUser.ADM_UserMasterId;
                        objDOADM_AccessGroupReportCorrelation.UTCLastUpdatedOn = ZoneLookupUI.ConvertToTimeZone(DateTime.UtcNow, TimeZone);
                        objDOADM_AccessGroupReportCorrelation.IsActive         = false;
                    }
                    break;

                case 2:                                                                                   //update existing Report
                    DOADM_AccessGroupReportCorrelation objOldDOADM_AccessGroupReportCorrelation = lstDOADM_AccessGroupReportCorrelation.Where(x => x.RPT_ReportsMasterRef == lPreviousReport).FirstOrDefault();
                    if (objOldDOADM_AccessGroupReportCorrelation.ADM_AccessGroupReportCorrelationId == 0) //updating a report for new record
                    {
                        objOldDOADM_AccessGroupReportCorrelation.CreatedByName = currentUser.FullName;
                        objOldDOADM_AccessGroupReportCorrelation.CreatedByRef  = currentUser.ADM_UserMasterId;
                    }
                    objOldDOADM_AccessGroupReportCorrelation.LastUpdatedByRef     = currentUser.ADM_UserMasterId;
                    objOldDOADM_AccessGroupReportCorrelation.UTCLastUpdatedOn     = ZoneLookupUI.ConvertToTimeZone(DateTime.UtcNow, TimeZone);
                    objDOADM_AccessGroupReportCorrelation.LastUpdatedByName       = currentUser.FullName;
                    objOldDOADM_AccessGroupReportCorrelation.IsActive             = true;
                    objOldDOADM_AccessGroupReportCorrelation.RPT_ReportsMasterRef = objDOADM_AccessGroupReportCorrelation.RPT_ReportsMasterRef;
                    break;

                case 3:    //removing all the lists from Session
                    foreach (var item in lstDOADM_AccessGroupReportCorrelation)
                    {
                        item.LastUpdatedByRef = currentUser.ADM_UserMasterId;
                        item.UTCLastUpdatedOn = ZoneLookupUI.ConvertToTimeZone(DateTime.UtcNow, TimeZone);
                        item.IsActive         = false;
                    }
                    break;
                }

                ViewBag.Reports = ViewBag.Reports = CacheUtility.GetAllReportsFromCache(null, "");

                Session[ConstantTexts.AccessGroupReportSessionKey] = lstDOADM_AccessGroupReportCorrelation;
                return(PartialView("_Reports", lstDOADM_AccessGroupReportCorrelation.Where(xx => xx.IsActive == true).ToList()));
            }
            catch (Exception ex)
            {
                BLCommon.LogError(currentUser.ADM_UserMasterId, MethodBase.GetCurrentMethod().Name, (long)ErrorModuleName.ManageAccessGroups, (long)ExceptionTypes.Uncategorized, ex.ToString(), ex.ToString());
                return(RedirectToAction("Maintenance", "Error", routeValues: ex.ToString()));
            }
        }