Exemplo n.º 1
0
        public ActionResult Create()
        {
            if (Session["Login"] != null)
            {
                LoginSession loginsession = (LoginSession)Session["Login"];
                ViewBag.CompanyLogo = loginsession.CompanyLogo;
                ViewBag.Layout1 = BAL.Common.LayoutType(loginsession.UserType);
                String actionName = this.ControllerContext.RouteData.Values["action"].ToString();
                String controllerName = this.ControllerContext.RouteData.Values["controller"].ToString();
                ViewBag.Menu = BAL.Common.GetActiveMenu(controllerName, actionName, BAL.Common.LayoutType(loginsession.UserType));
                ViewBag.RoleName = loginsession.RoleName;

                BAL.UserRegister objUserRegister = new BAL.UserRegister();
                ViewBag.Security = new SelectList(BAL.SecurityQuestion.SecurityQuestionDDR(), "Value", "Text");
                ViewBag.Role = new SelectList(BAL.RoleModels.RoleDDL(), "Value", "Text");
                UserInformation Userinfo = new UserInformation();
                Userinfo.UserID = Convert.ToInt64(loginsession.UserID);

                if (Userinfo.UserType()==1) //for others user
                {
                    Int64? ClientID = Userinfo.GetClientID();
                    if (Userinfo.GetClientID() != null)
                    {
                        String SelectClient = Userinfo.ClientList()[0].Value;
                        ViewBag.Client = new SelectList(Userinfo.ClientList(), "Value", "Text", SelectClient);

                        ViewBag.HiddenSycous = 1;//Userinfo.UserType();
                        objUserRegister.UserType = true;
                    }
                }
                if (Userinfo.UserType() == 0)
                { //for sycous user
                    ViewBag.Client = new SelectList(BAL.ClientModel.ClientDropDownList(), "Value", "Text");

                    ViewBag.HiddenSycous = 0;// false;
                    objUserRegister.UserType = false;

                }
                //return View();
                return View(objUserRegister);
            }
            else
            { return RedirectToAction("Index", "Home"); }
        }
Exemplo n.º 2
0
 public ActionResult Success(UserRegister model)
 {
     if (Session["Login"] != null)
     {
         return RedirectToAction("Index", "UserReg");
     }
     else
     { return RedirectToAction("Index", "Home"); }
 }
Exemplo n.º 3
0
        public ActionResult Update(UserRegister model)
        {
            if (Session["Login"] != null)
            {LoginSession loginsession = (LoginSession)Session["Login"];
            ViewBag.CompanyLogo = loginsession.CompanyLogo;
            ViewBag.Layout1 = BAL.Common.LayoutType(loginsession.UserType);
            String actionName = this.ControllerContext.RouteData.Values["action"].ToString();
            String controllerName = this.ControllerContext.RouteData.Values["controller"].ToString();
            ViewBag.Menu = BAL.Common.GetActiveMenu(controllerName, actionName, BAL.Common.LayoutType(loginsession.UserType));
            ViewBag.RoleName = loginsession.RoleName;

                try
                {

                    model.ModifyBy = Convert.ToInt64(loginsession.UserID);

                    foreach (string inputTagName in Request.Files)
                    {
                        HttpPostedFileBase file = Request.Files[inputTagName];

                        if (file.ContentLength > 0)
                        {
                            var fileName = Guid.NewGuid() + Path.GetExtension(file.FileName);
                            var path = Path.Combine(Server.MapPath("~/UserPicture"), fileName);
                            // filePath = Path.Combine(HttpContext.Server.MapPath("~/UserPicture"), Path.GetFileName(file.FileName));
                            file.SaveAs(path);
                            model.Photo = fileName.ToString().Trim();
                        }

                    }//foreach

                    if (model.User_ID != null)
                    {
                        // Usertype check (Exist value and old Value)
                        UserRegister Registration = new UserRegister();
                        Registration = BAL.RegistrationModels.EditUserRegistration(model.User_ID.ToString());
                        if (Registration.UserType == model.UserType)
                        {
                            if (RegistrationModels.UpdateUserRegistrationModel(model))
                            {
                                return RedirectToAction("Index", "UserReg");
                            }
                            else
                            {
                                return Content("Unable to Update , try again");
                            }
                        }
                        else
                        {
                            if (DAL.DALUserReg.IsExistsSitePermission(model.User_ID.ToString()))
                            {
                                if (RegistrationModels.UpdateUserRegistrationModel(model))
                                {
                                    return RedirectToAction("Index", "UserReg");
                                }
                                else
                                {
                                    return Content("Unable to Update , try again");
                                }
                            }
                            else
                            {
                                return Content("Delete Site permission of User Then you Can change the userType ");
                            }

                        }
                    }// userID Check

                }//try
                catch (Exception ex)
                {
                    return Content(ex.Message);
                }

            }
            else
            { return RedirectToAction("Index", "Home"); }
            return View(model);
        }
Exemplo n.º 4
0
        public ActionResult Edit(String User_ID)
        {
            if (Session["Login"] != null)
            {
                LoginSession loginsession = (LoginSession)Session["Login"];
                ViewBag.CompanyLogo = loginsession.CompanyLogo;
                ViewBag.Layout1 = BAL.Common.LayoutType(loginsession.UserType);
                String actionName = this.ControllerContext.RouteData.Values["action"].ToString();
                String controllerName = this.ControllerContext.RouteData.Values["controller"].ToString();
                ViewBag.Menu = BAL.Common.GetActiveMenu(controllerName, actionName, BAL.Common.LayoutType(loginsession.UserType));
                ViewBag.RoleName = loginsession.RoleName;

                if (User_ID != null)
                {
                    String Dec_UserID = BAL.Security.URLDecrypt(User_ID);
                    if ((Dec_UserID != "0") && (Dec_UserID != null))
                    {
                        UserRegister Registration = new UserRegister();
                        try
                        {
                            Registration = BAL.RegistrationModels.EditUserRegistration(Dec_UserID);
                            ViewBag.UserID = Registration.User_ID;

                            UserInformation Userinfo = new UserInformation();
                            Userinfo.UserID = Convert.ToInt64(loginsession.UserID);

                            if (Userinfo.UserType() == 1) //for others user
                            {

                                if (Registration.ClientID != null)
                                { ViewBag.Client = new SelectList(Userinfo.ClientList(), "Value", "Text", Registration.ClientID); }
                                else
                                {
                                            Int64? ClientID = Userinfo.GetClientID();
                                            if (Userinfo.GetClientID() != null)
                                            {
                                                String SelectClient = Userinfo.ClientList()[0].Value;
                                                ViewBag.Client = new SelectList(Userinfo.ClientList(), "Value", "Text", SelectClient);

                                                // objUserRegister.UserType = true;
                                            }
                                }
                                 ViewBag.HiddenSycous = "1";//Userinfo.UserType();
                            }
                            if (Userinfo.UserType() == 0)
                            { //for sycous user
                                if (Registration.ClientID != null)
                                {
                             ViewBag.Client = new SelectList(BAL.ClientModel.ClientDropDownList(), "Value", "Text", Registration.ClientID);
                             //ViewBag.HiddenSycous = 0;
                                }
                                else
                                {
                             ViewBag.Client = new SelectList(BAL.ClientModel.ClientDropDownList(), "Value", "Text" );
                                }
                              ViewBag.HiddenSycous = "0";// false;
                               // objUserRegister.UserType = false;
                            }

                        }
                        catch (Exception ex)
                        { return Content(ex.Message); }

                        return View(Registration);
                    }
                }
                else
                {
                    return RedirectToAction("Index", "UserReg");
                }
                return View();
            }
            else
            { return RedirectToAction("Index", "Home"); }
        }
Exemplo n.º 5
0
        public ActionResult MyImage(UserRegister model, String Command)
        {
            if (Session["Login"] != null)
            {
                LoginSession loginsession = (LoginSession)Session["Login"];
                ViewBag.CompanyLogo = loginsession.CompanyLogo;
                ViewBag.Layout1 = BAL.Common.LayoutType(loginsession.UserType);
                String actionName = this.ControllerContext.RouteData.Values["action"].ToString();
                String controllerName = this.ControllerContext.RouteData.Values["controller"].ToString();
                ViewBag.Menu = BAL.Common.GetActiveMenu(controllerName, actionName, BAL.Common.LayoutType(loginsession.UserType));
                ViewBag.RoleName = loginsession.RoleName;

                if (Command == "Save")
                {
                    String filePath = String.Empty;
                    foreach (string inputTagName in Request.Files)
                    {
                        HttpPostedFileBase file = Request.Files[inputTagName];

                        if (file.ContentLength > 0)
                        {
                            var fileName = Guid.NewGuid() + Path.GetExtension(file.FileName);
                            var path = Path.Combine(Server.MapPath("~/UserPicture"), fileName);
                            // filePath = Path.Combine(HttpContext.Server.MapPath("~/UserPicture"), Path.GetFileName(file.FileName));
                            file.SaveAs(path);
                            model.Photo = fileName.ToString().Trim();
                        }

                    }//foreach

                    if (model.Photo != null)
                    {
                        if (BAL.RegistrationModels.UpdateUserRegistration(model))
                        {
                            return RedirectToAction("Index", "UserReg");
                        }
                        else
                        { return RedirectToAction("Index", "UserReg"); }

                    }//if
                }//if
                else
                {
                    return RedirectToAction("Index", "UserReg");
                }

            }//
            else
            { return RedirectToAction("Index", "Home"); }

            return View();
        }
Exemplo n.º 6
0
        public ActionResult Create(UserRegister model)
        {
            if (Session["Login"] != null)
            {
                LoginSession loginsession = (LoginSession)Session["Login"];
                ViewBag.CompanyLogo = loginsession.CompanyLogo;
                ViewBag.Layout1 = BAL.Common.LayoutType(loginsession.UserType);
                String actionName = this.ControllerContext.RouteData.Values["action"].ToString();
                String controllerName = this.ControllerContext.RouteData.Values["controller"].ToString();
                ViewBag.Menu = BAL.Common.GetActiveMenu(controllerName, actionName, BAL.Common.LayoutType(loginsession.UserType));
                ViewBag.RoleName = loginsession.RoleName;

                if (String.IsNullOrEmpty(model.UserName.ToString()))
                {
                    ModelState.AddModelError("UserID", "Please Enter  UserID");
                }

                foreach (string inputTagName in Request.Files)
                {
                    HttpPostedFileBase file = Request.Files[inputTagName];

                    if (file.ContentLength > 0)
                    {
                        var fileName = Guid.NewGuid() + Path.GetExtension(file.FileName);
                        var path = Path.Combine(Server.MapPath("~/UserPicture"), fileName);
                        // filePath = Path.Combine(HttpContext.Server.MapPath("~/UserPicture"), Path.GetFileName(file.FileName));
                        file.SaveAs(path);
                        model.Photo = fileName.ToString().Trim();
                    }

                }//foreach

                ViewBag.Security = new SelectList(BAL.SecurityQuestion.SecurityQuestionDDR(), "Value", "Text");

                if (ModelState.IsValid)
                {
                    try
                    {
                        //-------------------------------------------------------------
                        MembershipCreateStatus createStatus;
                        System.Web.Security.Membership.CreateUser(model.UserName, model.Password, model.Email, model.HintQut, model.HintAns, isApproved: true, providerUserKey: null, status: out createStatus);
                        if (createStatus == MembershipCreateStatus.Success)
                        {
                            String User_ID = System.Web.Security.Membership.GetUser(model.UserName).ProviderUserKey.ToString();
                            if (User_ID != null)
                            {
                                model.MemberShipId = User_ID.ToString();
                                //if (BAL.RegistrationModels.CreateUserRegistration(model))
                                //{
                                //    FormsAuthentication.SetAuthCookie(model.UserName, createPersistentCookie: false);
                                //    return Json(new { result = 1, message = "Record was successfully Saved!" });

                                //}
                                //else
                                //{
                                //    return Json(new { result = 0, message = "Duplicate UserID " });

                                //}

                                if (model.MemberShipId != null)
                                {

                                    String ID = BAL.RegistrationModels.AddUserRegistration(model);

                                    if (ID != null)
                                    {
                                        model.User_ID = Convert.ToInt64(ID);
                                        if (model.RoleName != null)
                                        {
                                            Roles.AddUserToRole(model.UserName, model.RoleName);
                                        }
                                        TempData["Registration"] = model;
                                        TempData["message"] = "Successfully Saved Record";
                                        return RedirectToAction("Success", "UserReg");

                                        //return Json(new { result = 0, message = "Duplicate UserID " });
                                    }
                                    else
                                    { return Json(new { result = 0, message = "Duplicate UserID " }); }

                                }
                                else
                                { return Json(new { result = 0, message = "Duplicate UserID " }); }

                            }
                            else
                            {
                                return Json(new { result = 0, message = "Duplicate UserID " });
                            }
                        }
                        else { return Json(new { result = 0, message = "Duplicate UserID " }); }
                    }
                    catch (Exception ex)
                    {
                        return Json(new { result = 0, message = "ErrorMessage" + ":" + ex.StackTrace.ToString() });
                    }
                }//
                else
                {
                    String errorMessage = String.Empty;
                    String exception = String.Empty;

                    foreach (var modelStateVal in ViewData.ModelState.Values)
                    {
                        foreach (var error in modelStateVal.Errors)
                        {
                            errorMessage = error.ErrorMessage;
                            exception = error.Exception.ToString();
                        }
                    }

                    //  return Json(new { result = 0, message = "ErrorMessage" + ":" + exception });
                    return View();
                }//else

            }
            else
            { return RedirectToAction("Index", "Home"); }
        }
Exemplo n.º 7
0
 public static bool UpdateUserRegistrationModel(UserRegister registration)
 {
     Boolean flag = false;
     try
     {
         Icontext objinter = new BALUserRegister();
         flag = objinter.UpdateRecord(registration);
     }
     catch (Exception ex)
     {
         throw;
     }
     return flag;
 }
Exemplo n.º 8
0
        public static Boolean CreateUserRegistration(UserRegister registration)
        {
            Boolean flag = false;
            try
            {
                Icontext objtext = new BALUserRegister();
                flag = objtext.CreateRecord(registration);
            }
            catch (Exception ex)
            {
                throw;
            }

            return flag;
        }
Exemplo n.º 9
0
        public static String AddUserRegistration(UserRegister registration)
        {
            String user_id = String.Empty;
            try
            {
                IRecordSave objtext = new BALUserRegister();
                user_id = objtext.AddRecord(registration);
            }
            catch (Exception ex)
            {
                throw;
            }

            return user_id;
        }
Exemplo n.º 10
0
        public Object EditRecord(Int64 Id)
        {
            UserRegister Registration = new UserRegister();
            try
            {
                UserREG _user = DAL.DALUserReg.EditUserRegistration(Convert.ToInt64(Id));

                Registration.User_ID = _user.UserID;

                if (_user.UserName != null)
                {
                    Registration.UserName = _user.UserName.Trim();
                }

                if (_user.FirstName != null)
                {
                    Registration.FirstName = _user.FirstName;
                }
                if (_user.LastName != null)
                {
                    Registration.LastName = _user.LastName;
                }
                if (_user.Email != null)
                {
                    Registration.Email = _user.Email.Trim();
                }
                if (_user.Mobile != null)
                {
                    Registration.Mobile = _user.Mobile.Trim();
                }
                if (_user.Phone != null)
                {
                    Registration.phone = _user.Phone.Trim();
                }

                if (_user.Photo != null)
                {
                    Registration.Photo = _user.Photo.Trim();
                }

                if (_user.UserType== 0)
                {
                    Registration.UserType = false;
                }
                if (_user.UserType == 1)
                {
                    Registration.UserType = true;
                }

                if (_user.HintQuestion!=null)
                {
                    Registration.HintQut = _user.HintQuestion;
                }

                if (_user.HintAns != null)
                {
                    Registration.HintAns = _user.HintAns;
                }

                if (_user.ClientID != null)
                {
                    Registration.ClientID = _user.ClientID;
                }

                UserInformation Us = new UserInformation();
                Us.UserID = _user.UserID;
                Registration.Client = Us.GetUSERClientName();
                Registration.RoleName = Us.GetRoleName();

            }//try
            catch (Exception ex)
            {
                throw;
            }
            return Registration;
        }