Example #1
0
        public ActionResult Edit(Entities.User obj, int page)
        {
            try
            {
                //ModelState.Remove("class.property");
                if (_objUser.Validate(obj, "update"))
                {
                    TempData["Msg"] = "Email address already exist.";
                    return(RedirectToAction("Edit"));
                }

                _objUser.Update(obj);

                if (User.IsInRole("Admin"))
                {
                    Entities.UsersPassword usersPassword = new Entities.UsersPassword();
                    var objUsersPassword = _objUserPassword.Select(obj.Uid);

                    if (objUsersPassword != null)
                    {
                        objUsersPassword.Password = obj.Password;
                        objUsersPassword.Uid      = obj.Uid;
                        _objUserPassword.Update(objUsersPassword);
                    }

                    // UsersManager - Added 6/6/2016
                    {
                        Entities.UsersManager objUsersManager = new UsersManager();
                        objUsersManager.ManagerId = (int)obj.ManagerId;
                        objUsersManager.Uid       = obj.Uid;

                        Business.Interfaces.IUserManager userManager = new UserManager();
                        userManager.AddorUpdate(objUsersManager);
                    }
                }

                TempData["Msg"] = "User updated successfully.";

                //RedirectToLocal(page.ToString(), "Edit");
                return(RedirectToAction("Edit", new { page = page }));
            }
            catch (Exception exception)
            {
                // log error
                Business.Services.LogError.Insert(exception, (int)Session["UID"]);

                TempData["Msg"] = "Error: " + exception.Message;
                return(RedirectToAction("Edit"));
            }
        }
Example #2
0
        public ActionResult Edit(Entities.UsersPassword obj)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(View());
                }

                _objUserPassword.Update(obj);
                TempData["Msg"] = "Password was been updated.";
            }
            catch (Exception exception)
            {
                // log error
                Business.Services.LogError.Insert(exception, (int)Session["UID"]);

                TempData["Msg"] = "Error: " + exception.Message;
            }
            return(RedirectToAction("Edit", "Password", obj.Uid)); // View(obj);
        }
Example #3
0
        public ActionResult Login(Entities.UsersPassword obj, string returnUrl)
        {
            // if (!ModelState.IsValid)
            //     return View();

            try
            {
                var objUser = objUserPassword.Login(obj);
                if (objUser <= 0)
                {
                    TempData["Msg"] = "Email or Password was not found.";
                    return(View());
                }

                // log active
                Models.LogModels.CreateUserLog("Rent_LoginSuccess", 1, Request.UserHostAddress);

                // User is Authentication
                System.Web.Security.FormsAuthentication.SetAuthCookie(obj.User.Email.ToLower(), false);

                //set session id
                Session.Add("UID", objUser);

                //redirect page if returnUrl is not null
                return(RedirectToLocal(returnUrl));

                //return RedirectToAction("Index");
            }
            catch (Exception exception)
            {
                // log error
                Business.Services.LogError.Insert(exception, 0);

                TempData["Msg"] = "Error: " + exception.Message;
                return(View());
            }
        }