Example #1
0
 protected void Page_Load(object sender, EventArgs e)
 {
     try
     {
         HttpCookie CookieSession = Request.Cookies.Get("UserSession");
         Session["UID"] = CookieSession.Value.ToString();
         ProfileFormView.ChangeMode(FormViewMode.Edit);
         if (Database.IsSessionValid(CookieSession))
         {
             String type = Database.GetUserType(CookieSession.Value.ToString());
             if (type == null)
             {
                 Response.Redirect("../Default.aspx");
             }
             else if (type.ToLower() == "admin")
             {
                 Response.Redirect("./Admin.aspx");
             }
             user     = Database.getUserByID(CookieSession.Value.ToString());
             GameList = new List <Game>();
             foreach (int GID in Database.getGameIDs())
             {
                 GameList.Add(new Game(GID));
             }
         }
         else
         {
             Response.Redirect("../Default.aspx");
         }
     }
     catch
     {
         Response.Redirect("../Default.aspx");
     }
 }
Example #2
0
 protected void Page_Load(object sender, EventArgs e)
 {
     try
     {
         Session["UID"] = Request.Cookies.Get("UserSession").Value.ToString();
         ProfileFormView.ChangeMode(FormViewMode.Edit);
         if (Database.IsSessionValid(Request.Cookies.Get("UserSession")))
         {
             String type = Database.GetUserType(Session["UID"].ToString());
             if (type == null)
             {
                 Response.Redirect("../Default.aspx");
             }
             else if (type.ToLower() == "user")
             {
                 Response.Redirect("./User.aspx");
             }
             else if (type.ToLower() != "admin")
             {
                 Response.Redirect("../Default.aspx");
             }
         }
     } catch
     {
         Response.Redirect("../Default.aspx");
     }
 }
Example #3
0
        public async Task <IActionResult> Update([Bind("FirstName,LastName,ZonalOfficeId")] ProfileFormView profile)
        {
            if (ModelState.IsValid)
            {
                var userId = _userManager.GetUserId(HttpContext.User);
                var s      = _context.Staff.SingleOrDefault(m => m.Id == userId);
                if (!s.IsProfileSetUp)
                {
                    var p = new Profile()
                    {
                        FirstName     = profile.FirstName,
                        LastName      = profile.LastName,
                        DateCreated   = DateTime.Now,
                        ZonalOfficeId = profile.ZonalOfficeId,
                        StaffId       = userId,
                        ImagePath     = "-",
                    };

                    s.IsProfileSetUp = true;
                    _context.Staff.Update(s);
                    _context.Add(p);
                }
                else
                {
                    //select staffprofile and update it
                    var updateProfile = await _context.StaffProfile.SingleOrDefaultAsync(m => m.StaffId == s.Id);

                    updateProfile.FirstName     = profile.FirstName;
                    updateProfile.LastName      = profile.LastName;
                    updateProfile.ZonalOfficeId = profile.ZonalOfficeId;

                    _context.StaffProfile.Update(updateProfile);
                }

                await _context.SaveChangesAsync();

                //_flashMessage.Confirmation("Profile Update Successfully!");

                return(RedirectToRoute("Dashboard"));
            }

            ViewData["ZonalOfficeId"] = new SelectList(_context.ZonalOffice, "Id", "Name", profile.ZonalOfficeId);
            return(View("Update", profile));
        }
        protected void SubmitButton_Click(object sender, EventArgs e)
        {
            if (!Page.IsValid)
            {
                return;
            }

            MissingFieldsMessage.Visible = false;

            var contact = XrmContext.MergeClone(Contact);

            ManageLists(XrmContext, contact);

            ProfileFormView.UpdateItem();

            var returnUrl = Request["returnurl"];

            if (!string.IsNullOrWhiteSpace(returnUrl))
            {
                Context.RedirectAndEndResponse(returnUrl);
            }
        }
        protected void SubmitButton_Click(object sender, EventArgs e)
        {
            if (!Page.IsValid)
            {
                return;
            }

            MissingFieldsMessage.Visible = false;

            var contact = XrmContext.MergeClone(Contact);

            ManageLists(XrmContext, contact);

            ProfileFormView.UpdateItem();

            var returnUrl = Request["returnurl"];

            var languageContext = this.Context.GetContextLanguageInfo();

            if (languageContext.IsCrmMultiLanguageEnabled && _forceRedirect)
            {
                // When forcing redirect for language change, make the confirmation message visible after redirect
                // It is only needed when redirecting back to Profile page
                if (string.IsNullOrWhiteSpace(returnUrl))
                {
                    Session[ConfirmationOneTimeMessageSessionKey] = true;
                }

                // respect returnUrl if it was provided during the form submit
                // otherwise, redirect back to current page
                var redirectUri = string.IsNullOrWhiteSpace(returnUrl) ? Request.Url : returnUrl.AsAbsoluteUri(Request.Url);
                returnUrl = languageContext.FormatUrlWithLanguage(overrideUri: redirectUri);
            }

            if (!string.IsNullOrWhiteSpace(returnUrl))
            {
                Context.RedirectAndEndResponse(returnUrl);
            }
        }
Example #6
0
        // GET: Profiles/Create
        public async Task <IActionResult> Update()
        {
            ViewData["ZonalOfficeId"] = new SelectList(_context.ZonalOffice, "Id", "Name");

            //check if profile already updated
            var userId = _userManager.GetUserId(HttpContext.User);
            var s      = _context.Staff.SingleOrDefault(m => m.Id == userId);

            if (s.IsProfileSetUp)
            {
                var profile = await _context.StaffProfile.SingleOrDefaultAsync(m => m.StaffId == userId);

                var profileView = new ProfileFormView()
                {
                    FirstName     = profile.FirstName,
                    LastName      = profile.LastName,
                    ZonalOfficeId = profile.ZonalOfficeId
                };
                return(View("Update", profileView));
            }

            return(View("Update"));
        }