Esempio n. 1
0
 public ActionResult Create(User user)
 {
     if (ModelState.IsValid)
     {
         if (Session["FileName"] != null)
         {
             var physicalPath = MiscUtility.GetPhysicalFilePath(Constants.Paths.TemporaryFileUploadPath, Session["FileName"].ToString());
             user.Photo = Utility.ReadFile(physicalPath);
         }
         userRepository.InsertOrUpdate(user);
         userRepository.Save();
         return RedirectToAction("Index");
     }
     else
     {
         ViewBag.PossibleUserRoles = userroleRepository.All;
         return View(user);
     }
 }
Esempio n. 2
0
 public void InsertOrUpdate(User user)
 {
     if (user != null && user.UserLoginName.IsNotNullOrEmpty())
     {
         if (user.Password.IsNotNullOrEmpty())
         {
             User existingUser = context.User.SingleOrDefault(u => u.UserLoginName.ToLower() == user.UserLoginName.ToLower());
             user.Password = CryptographyHelper.Encrypt(user.Password);
             user.CreatedDate = DateTime.Now;
             if(existingUser==null || (existingUser!=null && existingUser.UserID==user.UserID))
             {
                 if (user.UserID == default(int))
                 {
                     // New entity
                     context.User.Add(user);
                 }
                 else
                 {
                     context.Entry(existingUser).State = EntityState.Detached;
                     // Existing entity
                     context.Entry(user).State = EntityState.Modified;
                 }
             }
             else
             {
                 throw new CustomException(CustomExceptionType.CommonDuplicacy, "User is already there in the sytem with the provided user name");
             }
         }
         else
         {
             throw new CustomException(CustomExceptionType.CommonArgumentNullException, "[Password] is not provided while saving a user");
         }
     }
     else
     {
         throw new CustomException(CustomExceptionType.CommonArgumentNullException, "[UserLoginName] is not provided while saving a user");
     }
 }
Esempio n. 3
0
 public ViewResult Search(User searchUser)
 {
     if (searchUser != null)
     {
     }
     return View("Index", userRepository.AllIncluding(user => user.UserRole));
 }
Esempio n. 4
0
 public ActionResult Create()
 {
     User user = new User();
     ViewBag.PossibleUserRoles = userroleRepository.All;
     return View(user);
 }
Esempio n. 5
0
 public ActionResult LogOn(User user)
 {
     if (UserAuthentication.AuthenticateUser(user.UserLoginName, user.Password, true, userRepository))
     {
         string returnUrl = string.Empty;
         if (Request.UrlReferrer != null)
         {
             returnUrl = Request.UrlReferrer.Query.Replace("?ReturnUrl=", string.Empty);
             returnUrl = HttpUtility.UrlDecode(returnUrl);
         }
         if (Url.IsLocalUrl(returnUrl))
         {
             return Redirect(returnUrl);
         }
         else
         {
             return RedirectToAction("Index", "Home", new { Area = string.Empty });
         }
     }
     else
     {
         return View();
     }
 }