Exemple #1
0
        protected override async Task OnInitializedAsync()
        {
            Claim            = new CreateExpenseClaimFrontCommand();
            Claim.SubmitDate = DateTime.Today;
            Items            = new List <CreateExpenseItemFrontCommand>();
            Categories       = await Mediator.Send(new GetAllExpenseCategoriesFrontQuery());

            Currencies = await Mediator.Send(new GetAllCurrenciesFrontQuery());

            var users = await AuthenticationService.GetUsers();

            foreach (UserResponseVM user in users)
            {
                if (user.Roles.Contains("Approver"))
                {
                    Approvers.Add(user);
                }
            }
            AuthenticationState authenticationState;

            authenticationState = await AuthenticationStateProvider.GetAuthenticationStateAsync();

            this.AuthenticationStateProviderUser = authenticationState.User;
            Claim.RequesterId = AuthenticationStateProviderUser.Claims.FirstOrDefault(c => c.Type == "uid").Value;
        }
Exemple #2
0
        public ActionResult DeleteConfirmed(string id)
        {
            Approvers approvers = db.Approvers.Find(id);

            db.Approvers.Remove(approvers);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Exemple #3
0
 public ActionResult Edit([Bind(Include = "PSUPassport,TitleName,Name,LastName,OrganName,Position,Email,Tel")] Approvers approvers)
 {
     if (ModelState.IsValid)
     {
         db.Entry(approvers).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(approvers));
 }
Exemple #4
0
        public ActionResult Create([Bind(Include = "PSUPassport,TitleName,Name,LastName,OrganName,Position,Email,Tel")] Approvers approvers)
        {
            if (ModelState.IsValid)
            {
                db.Approvers.Add(approvers);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(approvers));
        }
Exemple #5
0
        // GET: Approvers/Delete/5
        public ActionResult Delete(string id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Approvers approvers = db.Approvers.Find(id);

            if (approvers == null)
            {
                return(HttpNotFound());
            }
            return(View(approvers));
        }
        static public Approvers getAdvApprovers(AP_Staff_AdvanceRequest adv, double LargeTransaction, DotNetNuke.Entities.Users.UserInfo authUser, DotNetNuke.Entities.Users.UserInfo authAuthUser)
        {
            StaffBroker.StaffBrokerDataContext dStaff = new StaffBroker.StaffBrokerDataContext();
            Approvers rtn = new Approvers();

            var st = StaffBrokerFunctions.GetStaffMember((int)adv.UserId);

            rtn.Name = st.DisplayName;
            int SpouseId = StaffBrokerFunctions.GetSpouseId((int)adv.UserId);

            rtn.AmountSpecial = ((double)adv.RequestAmount) > LargeTransaction;

            rtn.SpouseSpecial = false;
            rtn.UserIds       = new List <DotNetNuke.Entities.Users.UserInfo>();

            var app2 = StaffBrokerFunctions.GetLeaders((int)adv.UserId, true);

            rtn.SpouseSpecial = (app2.Count() == 1 && ((app2.First() == SpouseId) || (app2.First() == (int)adv.UserId)));
            if (rtn.AmountSpecial || rtn.SpouseSpecial || app2.Count() == 0)
            {
                rtn.UserIds.Add(authUser.UserID == adv.UserId ? authAuthUser : authUser);

                if (app2.Contains((authUser.UserID == adv.UserId ? (authAuthUser.UserID) : authUser.UserID)))
                {
                    rtn.AmountSpecial = false;
                }
            }
            else
            {
                foreach (int i in (from c in app2 where c != adv.UserId && c != SpouseId select c))
                {
                    rtn.UserIds.Add(DotNetNuke.Entities.Users.UserController.GetUserById(adv.PortalId, i));
                }
            }



            return(rtn);
        }
		/// <summary>
		/// Code Added by Cognizant on 04/19/2005 as part of Cashier Recon Enhancements
		/// Fill a Drop Down with Approvers 
		/// </summary>
		public void FillApproversDropDown(DropDownList drpApprovers, string sRepDO)
		{
			DataTable Approvers;
			
			Authentication Auth = new Authentication();
						
			DataSet dsApprovers = Auth.ListApprovers(sRepDO);

			Approvers = dsApprovers.Tables[0];
			DataRow dr =  Approvers.NewRow();
			dr["USERNAME"] = "******";
			dr["USERDEF"] = "All";
			// Add the row to the rows collection.
			Approvers.Rows.InsertAt(dr,0);
			// Set values in the columns:
			Approvers.Columns.Add("csrUser", typeof(String), "USERDEF");
			drpApprovers.DataSource = Approvers.DefaultView;
			drpApprovers.DataTextField = "csrUser";
			drpApprovers.DataValueField = "USERNAME";
			drpApprovers.DataBind();
			drpApprovers.SelectedIndex = 0;
			
		}
        public static Approvers getApprovers(AP_Staff_Rmb rmb, DotNetNuke.Entities.Users.UserInfo authUser, DotNetNuke.Entities.Users.UserInfo authAuthUser)
        {
            StaffBroker.StaffBrokerDataContext dStaff = new StaffBroker.StaffBrokerDataContext();
            Approvers rtn = new Approvers();

            var st = StaffBrokerFunctions.GetStaffMember(rmb.UserId);
            rtn.Name = st.DisplayName;
            int SpouseId = StaffBrokerFunctions.GetSpouseId(rmb.UserId);
            rtn.AmountSpecial = (from c in rmb.AP_Staff_RmbLines where c.LargeTransaction == true select c).Count() > 0;
            rtn.isDept = (rmb.CostCenter != st.CostCenter);
            rtn.SpouseSpecial = false;
            rtn.UserIds = new List<DotNetNuke.Entities.Users.UserInfo>();
            if (rtn.isDept)
            {
                var cc = from c in dStaff.AP_StaffBroker_Departments where (c.CostCentre == rmb.CostCenter) && c.PortalId == rmb.PortalId select c;
                rtn.CCMSpecial = (from c in cc
                                  where ((c.CostCentreManager == null && c.CostCentreDelegate == null) == false) &&
                                      (
                                      ((c.CostCentreManager != rmb.UserId) && (c.CostCentreManager != SpouseId)) ||
                                      ((c.CostCentreDelegate != rmb.UserId) && (c.CostCentreDelegate != SpouseId))

                                      )
                                  select c.CostCenterId).Count() == 0;

                if(rtn.CCMSpecial && !(cc.First().CostCentreManager==null && cc.First().CostCentreDelegate==null))
                {
                    //Try to add the CCM's own Team Leader instead of auth User
                    var app2 = StaffBrokerFunctions.GetLeaders(rmb.UserId, true);
                    foreach (int i in (from c in app2 where c != rmb.UserId && c != SpouseId select c))
                        rtn.UserIds.Add(DotNetNuke.Entities.Users.UserController.GetUserById(rmb.PortalId, i));

                }
                if ((rtn.CCMSpecial && rtn.UserIds.Count()==0 )|| rtn.AmountSpecial || rtn.SpouseSpecial)
                {
                    rtn.UserIds.Clear();
                    rtn.UserIds.Add(authUser.UserID == rmb.UserId ? authAuthUser : authUser);

                    if (cc.First().CostCentreManager == rtn.UserIds.First().UserID || cc.First().CostCentreDelegate == rtn.UserIds.First().UserID)
                    {
                        rtn.AmountSpecial = false;
                        rtn.CCMSpecial = false;
                    }

                }
                else
                {

                    if (cc.First().CostCentreManager != rmb.UserId && cc.First().CostCentreManager != SpouseId && cc.First().CostCentreManager != null)
                        rtn.UserIds.Add(DotNetNuke.Entities.Users.UserController.GetUserById(rmb.PortalId, (int)cc.First().CostCentreManager));
                    if (cc.First().CostCentreDelegate != rmb.UserId && cc.First().CostCentreDelegate != SpouseId && cc.First().CostCentreDelegate != null)
                        rtn.UserIds.Add(DotNetNuke.Entities.Users.UserController.GetUserById(rmb.PortalId, (int)cc.First().CostCentreDelegate));

                }
                if (cc.Count() > 0)
                    rtn.Name = cc.First().Name;

            }
            else
            {
                rtn.CCMSpecial = false;
                var app2 = StaffBrokerFunctions.GetLeaders(rmb.UserId, true);
                rtn.SpouseSpecial = (app2.Count() == 1 && ((app2.First() == SpouseId) || (app2.First() == rmb.UserId)));
                if (rtn.AmountSpecial || rtn.SpouseSpecial || app2.Count() == 0)
                {
                    rtn.UserIds.Add(authUser.UserID == rmb.UserId ? authAuthUser : authUser);

                    if (app2.Contains(rtn.UserIds.First().UserID))
                    {
                        rtn.AmountSpecial = false;
                    }
                }
                else
                {
                    foreach (int i in (from c in app2 where c != rmb.UserId && c != SpouseId select c))
                        rtn.UserIds.Add(DotNetNuke.Entities.Users.UserController.GetUserById(rmb.PortalId, i));
                }

            }

            if(rtn.UserIds.Count()==0)
                rtn.UserIds.Add(authUser.UserID == rmb.UserId ? authAuthUser : authUser);

            return rtn;
        }
        public static Approvers getAdvApprovers(AP_Staff_AdvanceRequest  adv, double LargeTransaction, DotNetNuke.Entities.Users.UserInfo authUser, DotNetNuke.Entities.Users.UserInfo authAuthUser)
        {
            StaffBroker.StaffBrokerDataContext dStaff = new StaffBroker.StaffBrokerDataContext();
            Approvers rtn = new Approvers();

            var st = StaffBrokerFunctions.GetStaffMember((int)adv.UserId );
            rtn.Name = st.DisplayName;
            int SpouseId = StaffBrokerFunctions.GetSpouseId((int)adv.UserId);
            rtn.AmountSpecial = ((double)adv.RequestAmount)>LargeTransaction ;

            rtn.SpouseSpecial = false;
            rtn.UserIds = new List<DotNetNuke.Entities.Users.UserInfo>();

            var app2 = StaffBrokerFunctions.GetLeaders((int)adv.UserId, true);
            rtn.SpouseSpecial = (app2.Count() == 1 && ((app2.First() == SpouseId) || (app2.First() == (int)adv.UserId)));
            if (rtn.AmountSpecial || rtn.SpouseSpecial || app2.Count() == 0)
            {
                rtn.UserIds.Add(authUser.UserID == adv.UserId ? authAuthUser : authUser);

                if (app2.Contains((authUser.UserID == adv.UserId ? (authAuthUser.UserID) : authUser.UserID)))
                {
                    rtn.AmountSpecial = false;
                }
            }
            else
            {
                foreach (int i in (from c in app2 where c != adv.UserId && c != SpouseId select c))
                    rtn.UserIds.Add(DotNetNuke.Entities.Users.UserController.GetUserById(adv.PortalId, i));
            }

            return rtn;
        }
Exemple #10
0
        public async Task <ActionResult> GetRequestDetails(RequestDetails requestInfo)
        {
            try
            {
                //Assign UI synch request details to SynchRequestDTO model
                SynchRequestDTO syncRequest = requestInfo.syncRequest;
                //Assign user id to SynchRequestDTO model
                syncRequest.userId = userid;
                //Api Controller object initialization
                APIController apiControllerObj = new APIController();
                //Get request details from Synch API
                string stApprovalrequest = await apiControllerObj.GetRequestInfo(syncRequest, requestInfo.requestID);

                //Get Approval List details from Synch API
                string strApproverList = await apiControllerObj.GetApprovers(syncRequest, requestInfo.requestID);

                //Deseralize the result returned by the API
                UserRequestJsonData  userBackendjsonResponse  = JsonConvert.DeserializeObject <UserRequestJsonData>(stApprovalrequest);
                UserApprovalJsonData userApprovaljsonResponse = JsonConvert.DeserializeObject <UserApprovalJsonData>(strApproverList);
                //creates list request details object
                List <ApprovalRequestDTO> requestsDetails = new List <ApprovalRequestDTO>();
                //Checks whether the JSON response is not null
                if (userBackendjsonResponse != null && userApprovaljsonResponse != null)
                {
                    //Create ApprovalRequestDTO Model object
                    ApprovalRequestDTO requestObj = new ApprovalRequestDTO();
                    //Iterate json format result and bind to Model
                    foreach (userBackendRequest userbackendRequestdetails in userBackendjsonResponse.userBackendRequestinfo)
                    {
                        //Create ApprovalDTO Model object
                        requestObj.approval = new ApprovalDTO();
                        //Create RequestDTO Model object
                        requestObj.request = new RequestDTO();
                        if (userbackendRequestdetails.requestDetails != null)
                        {
                            //Get Request ID from Json reuslt
                            requestObj.request.ID = userbackendRequestdetails.requestDetails.ID;
                            //Get Request Title from Json reuslt
                            requestObj.request.Title = userbackendRequestdetails.requestDetails.Title;
                            //Get Request Status from Json reuslt
                            requestObj.request.Status = userbackendRequestdetails.requestDetails.Status;
                            //Get Request Created from Json reuslt
                            DateTime?created = userbackendRequestdetails.requestDetails.Created;
                            if (created != null)
                            {
                                requestObj.request.Created = created.Value;
                            }
                            //Get Request Requester details from Json reuslt
                            requestObj.request.Requester = new RequesterDTO();
                            //Get Requester UserID from Json reuslt
                            if (requestObj.request.Requester.UserID == null)
                            {
                                requestObj.request.Requester.UserID = userbackendRequestdetails.requestDetails.Requester.UserID;
                            }
                            //Get Requester UserID from Json reuslt
                            if (requestObj.request.Requester.Name == null)
                            {
                                requestObj.request.Requester.Name = userbackendRequestdetails.requestDetails.Requester.Name;
                            }
                            //Creates list request fields object
                            List <FieldDTO> requestFields = new List <FieldDTO>();
                            //Checks whether the JSON response is not null
                            if (userbackendRequestdetails.requestDetails.Fields.Overview != null && userbackendRequestdetails.requestDetails.Fields.Overview.Count > 0)
                            {
                                //Iterate json format result and bind to Model
                                foreach (FieldDTO field in userbackendRequestdetails.requestDetails.Fields.Overview)
                                {
                                    //Create FieldDTO Model object for Overview fields
                                    FieldDTO overviewFields = new FieldDTO();
                                    //Get Overview fields Name from Json reuslt
                                    overviewFields.Name = field.Name;
                                    //Get Overview fields Value from Json reuslt
                                    overviewFields.Value = field.Value;
                                    //Get Overview fields Group from Json reuslt
                                    overviewFields.Group = field.Group;
                                    //Add to FieldDTO Model object
                                    requestFields.Add(overviewFields);
                                }
                            }
                            //Checks whether the JSON response is not null
                            if (userbackendRequestdetails.requestDetails.Fields.GenericInfo != null && userbackendRequestdetails.requestDetails.Fields.Overview.Count > 0)
                            {
                                //Iterate json format result and bind to Model
                                foreach (FieldDTO field in userbackendRequestdetails.requestDetails.Fields.GenericInfo)
                                {
                                    //Create FieldDTO Model object for Generic fields
                                    FieldDTO genericInfoFields = new FieldDTO();
                                    //Get Generic fields Name/Value pair from Json reuslt
                                    genericInfoFields.Name  = field.Name;
                                    genericInfoFields.Value = field.Value;
                                    //Get Generic fields Group from Json reuslt
                                    genericInfoFields.Group = field.Group;
                                    //Add to FieldDTO Model object
                                    requestFields.Add(genericInfoFields);
                                }
                            }
                            //Creates list approval list object
                            List <Approvers> approverList = new List <Approvers>();
                            //Iterate json format result and bind to Model
                            foreach (ApproversJson userApprovalJsondetails in userApprovaljsonResponse.userApprovalinfo)
                            {
                                //Create Approvers Model object for Approval details
                                Approvers userApprovaldetails = new Approvers();
                                //Get Approval Order info
                                userApprovaldetails.Order = userApprovalJsondetails.Order;
                                //Get Approval Order UserID
                                userApprovaldetails.UserID = userApprovalJsondetails.UserID;
                                //Get Approval Order UserName
                                userApprovaldetails.UserName = userApprovalJsondetails.UserName;
                                //Get Approval Order Status
                                userApprovaldetails.Status = userApprovalJsondetails.Status;
                                //Get Approval Order Created
                                userApprovaldetails.Created = userApprovalJsondetails.Created;
                                //Get Approval Order DueDate
                                userApprovaldetails.DueDate = userApprovalJsondetails.DueDate;
                                //Get Approval Order DecisionDate
                                userApprovaldetails.DecisionDate = userApprovalJsondetails.DecisionDate;
                                //getting Approver Comment
                                userApprovaldetails.Comment = userApprovalJsondetails.Comment;
                                //Add to Approvers Model object for Approval details
                                approverList.Add(userApprovaldetails);
                            }
                            //Add approval list to ApprovalRequestDTO Model object
                            requestObj.request.Approvers = approverList;
                            //Add Overview /Generic fields to ApprovalRequestDTO Model object
                            requestObj.request.Fields = requestFields;
                        }
                        else
                        {
                            requestObj.request    = null;
                            requestObj.approval   = null;
                            requestObj.retryAfter = userbackendRequestdetails.retryAfter;
                        }
                        //Add all info to ApprovalRequestDTO Model object List
                        requestsDetails.Add(requestObj);
                    }
                }
                // Return Json formate object and pass to UI
                return(Json(requestsDetails, JsonRequestBehavior.AllowGet));
            }
            catch (Exception exception)
            {
                LoggerHelper.WriteToLog(exception + " - Error while creating client context : "
                                        + exception.ToString(), CoreConstants.Priority.High, CoreConstants.Category.Error);
                return(View("Error"));
            }
        }
        static public Approvers getApprovers(AP_Staff_Rmb rmb, DotNetNuke.Entities.Users.UserInfo authUser, DotNetNuke.Entities.Users.UserInfo authAuthUser)
        {
            StaffBroker.StaffBrokerDataContext dStaff = new StaffBroker.StaffBrokerDataContext();
            Approvers rtn = new Approvers();

            var st = StaffBrokerFunctions.GetStaffMember(rmb.UserId);

            rtn.Name = st.DisplayName;
            int SpouseId = StaffBrokerFunctions.GetSpouseId(rmb.UserId);

            rtn.AmountSpecial = (from c in rmb.AP_Staff_RmbLines where c.LargeTransaction == true select c).Count() > 0;
            rtn.isDept        = (rmb.CostCenter != st.CostCenter);
            rtn.SpouseSpecial = false;
            rtn.UserIds       = new List <DotNetNuke.Entities.Users.UserInfo>();
            if (rtn.isDept)
            {
                var cc = from c in dStaff.AP_StaffBroker_Departments where (c.CostCentre == rmb.CostCenter) && c.PortalId == rmb.PortalId select c;
                rtn.CCMSpecial = (from c in cc
                                  where ((c.CostCentreManager == null && c.CostCentreDelegate == null) == false) &&
                                  (
                                      ((c.CostCentreManager != rmb.UserId) && (c.CostCentreManager != SpouseId)) ||
                                      ((c.CostCentreDelegate != rmb.UserId) && (c.CostCentreDelegate != SpouseId))

                                  )
                                  select c.CostCenterId).Count() == 0;

                if (rtn.CCMSpecial || rtn.AmountSpecial || rtn.SpouseSpecial)
                {
                    rtn.UserIds.Add(authUser.UserID == rmb.UserId ? authAuthUser : authUser);

                    if (cc.First().CostCentreManager == rtn.UserIds.First().UserID || cc.First().CostCentreDelegate == rtn.UserIds.First().UserID)
                    {
                        rtn.AmountSpecial = false;
                        rtn.CCMSpecial    = false;
                    }
                }
                else
                {
                    if (cc.First().CostCentreManager != rmb.UserId && cc.First().CostCentreManager != SpouseId && cc.First().CostCentreManager != null)
                    {
                        rtn.UserIds.Add(DotNetNuke.Entities.Users.UserController.GetUserById(rmb.PortalId, (int)cc.First().CostCentreManager));
                    }
                    if (cc.First().CostCentreDelegate != rmb.UserId && cc.First().CostCentreDelegate != SpouseId && cc.First().CostCentreDelegate != null)
                    {
                        rtn.UserIds.Add(DotNetNuke.Entities.Users.UserController.GetUserById(rmb.PortalId, (int)cc.First().CostCentreDelegate));
                    }
                }
                if (cc.Count() > 0)
                {
                    rtn.Name = cc.First().Name;
                }
            }
            else
            {
                rtn.CCMSpecial = false;
                var app2 = StaffBrokerFunctions.GetLeaders(rmb.UserId, true);
                rtn.SpouseSpecial = (app2.Count() == 1 && ((app2.First() == SpouseId) || (app2.First() == rmb.UserId)));
                if (rtn.AmountSpecial || rtn.SpouseSpecial || app2.Count() == 0)
                {
                    rtn.UserIds.Add(authUser.UserID == rmb.UserId ? authAuthUser : authUser);

                    if (app2.Contains(rtn.UserIds.First().UserID))
                    {
                        rtn.AmountSpecial = false;
                    }
                }
                else
                {
                    foreach (int i in (from c in app2 where c != rmb.UserId && c != SpouseId select c))
                    {
                        rtn.UserIds.Add(DotNetNuke.Entities.Users.UserController.GetUserById(rmb.PortalId, i));
                    }
                }
            }

            if (rtn.UserIds.Count() == 0)
            {
                rtn.UserIds.Add(authUser.UserID == rmb.UserId ? authAuthUser : authUser);
            }



            return(rtn);
        }
        public PartialViewResult _Navigation()
        {
            UserViewModel model;

            if (CurrentCedUser != null)
            {
                var roles = CurrentCedUser.Roles.ToList().Select(x => x.Name);

                var mustBePrimaryDirector = !CurrentCedUser.IsSuperAdmin;
                var draftsCount           = EditionServices.GetEditionsCount(
                    CurrentCedUser.CurrentUser.Email,
                    null,
                    mustBePrimaryDirector,
                    WebConfigHelper.MinFinancialYear,
                    new List <EditionStatusType> {
                    EditionStatusType.Draft, EditionStatusType.PreDraft
                }.ToArray(),
                    Utility.Constants.ValidEventTypesForCed,
                    Utility.Constants.ValidEventActivitiesForCed);

                mustBePrimaryDirector = !(CurrentCedUser.IsSuperAdmin || CurrentCedUser.IsApprover);
                var waitingForApprovalsCount = EditionServices.GetEditionsCount(
                    CurrentCedUser.CurrentUser.Email,
                    null,
                    mustBePrimaryDirector,
                    WebConfigHelper.MinFinancialYear,
                    new List <EditionStatusType> {
                    EditionStatusType.WaitingForApproval
                }.ToArray(),
                    Utility.Constants.ValidEventTypesForCed,
                    Utility.Constants.ValidEventActivitiesForCed);

                var approvedsCount = EditionServices.GetEditionsCount(
                    CurrentCedUser.CurrentUser.Email,
                    null,
                    mustBePrimaryDirector,
                    WebConfigHelper.MinFinancialYear,
                    new List <EditionStatusType> {
                    EditionStatusType.Approved
                }.ToArray(),
                    Utility.Constants.ValidEventTypesForCed,
                    Utility.Constants.ValidEventActivitiesForCed);

                var profilePictureUrl      = UserServices.GetProfilePictureUrl(CurrentCedUser.CurrentUser.UserId);
                var emptyProfilePictureUrl = AzureStorageHelper.ImageBlobDirectory + Utility.Constants.NoProfilePicFileName;

                model = new UserViewModel
                {
                    UserId                 = CurrentCedUser.CurrentUser.UserId,
                    FullName               = CurrentCedUser.CurrentUser.Name + " " + CurrentCedUser.CurrentUser.Surname,
                    RoleNames              = string.Join(",", roles),
                    ProfilePictureUrl      = profilePictureUrl,
                    EmptyProfilePictureUrl = emptyProfilePictureUrl,
                    DraftCount             = draftsCount,
                    ApprovalCount          = waitingForApprovalsCount,
                    ApprovedCount          = approvedsCount,
                    CurrentUser            = CurrentCedUser,
                    Approvers              = string.Join("; ", Approvers.Select(x => x.Email))
                };
            }
            else
            {
                model = new UserViewModel
                {
                    Approvers = string.Join("; ", Approvers.Select(x => x.Email))
                };
            }

            return(PartialView("_Navigation", model));
        }