public ActionResult Edit(int id, VTSUSER model) { try { ViewBag.ReturnUrl = Url.Action("Edit"); if (ModelState.IsValid) { var updateModel = UserRepository.Update(id, model); if (updateModel) { return(RedirectToAction("Edit", new { Message = "Update Successfully" })); } else { AddErrors(VTSConstants.Error); } } // If we got this far, something failed, redisplay form return(View(model)); } catch { return(View(model)); } }
public ActionResult Manage(VTSUSER model, HttpPostedFileBase imagefile) { ViewBag.ReturnUrl = Url.Action("Manage"); if (ModelState.IsValid) { //var validateUploadFile = ValidaetUploadedFile(imagefile); //if (!validateUploadFile.IsNull()) //{ // AddErrors(validateUploadFile); // return View(model); //} var newFilePath = UploadFileDeleteExisting(imagefile, model.Email.GetName(), model.Photo, true);; model.Photo = !newFilePath.IsNull() ? newFilePath : model.Photo; var updateModel = UserRepository.Update(Email, model); if (updateModel) { return(RedirectToAction("Manage", new { Message = "Update Profile Successfully" })); } else { AddErrors(VTSConstants.Error); } } // If we got this far, something failed, redisplay form return(View(model)); }
public ActionResult CreateUser(RegisterViewModel model, HttpPostedFileBase imagefile) { if (ModelState.IsValid) { // TODO : Check for file upload filter. VTSUSER objUser = new VTSUSER(); objUser.Address = model.Address; objUser.City = model.City; objUser.IsActive = true; objUser.CreatedOn = DateTime.Now; if (!string.IsNullOrEmpty(model.DOB)) { try { objUser.DOB = Convert.ToDateTime(model.DOB); } catch { ModelState.AddModelError("DOB", "Invalid date of birth"); return(View(model)); } } objUser.Email = model.Email; objUser.FirstName = model.FirstName; objUser.IsAdmin = model.IsAdmin; objUser.LastName = model.LastName; objUser.Password = model.Password; objUser.Phone = model.Phone; objUser.Photo = model.Photo; objUser.Pincode = model.Pin; objUser.Sex = Convert.ToBoolean(model.Sex.ToGenderConversion()); objUser.State = model.State; objUser.Photo = UploadFileDeleteExisting(imagefile, objUser.Email.GetName()); if (UserRepository.Get(objUser.Email) != null) { AddErrors("Email already exists"); return(View(model)); } var createdUser = UserRepository.Create(objUser); if (createdUser != null) { return(RedirectToAction("ViewAllUsers", "Home")); } else { AddErrors(VTSConstants.Error); } } // If we got this far, something failed, redisplay form return(View(model)); }
bool CheckLogin(VTSUSER user) { if (user == null) { return(false); } if (user.IsAdmin) { return(true); } return((user.CreatedOn.Value.Subtract(DateTime.Now).Days > 180) ? false : true); }
public ActionResult Register(RegisterViewModel model, HttpPostedFileBase imagefile) { if (ModelState.IsValid) { // TODO : Check for file upload filter. VTSUSER objUser = new VTSUSER(); objUser.Address = model.Address; objUser.City = model.City; objUser.CreatedOn = DateTime.Now; if (!string.IsNullOrEmpty(model.DOB)) { try { objUser.DOB = Convert.ToDateTime(model.DOB); } catch { ModelState.AddModelError("DOB", "Invalid date of birth"); return(View(model)); } } objUser.Email = model.Email; objUser.FirstName = model.FirstName; objUser.IsActive = false; objUser.IsAdmin = false; objUser.LastName = model.LastName; objUser.Password = model.Password; objUser.Phone = model.Phone; objUser.Photo = model.Photo; objUser.Pincode = model.Pin; objUser.Sex = Convert.ToBoolean(model.Sex.ToGenderConversion()); objUser.State = model.State; objUser.Photo = UploadFileDeleteExisting(imagefile, objUser.Email.GetName()); if (UserRepository.Get(objUser.Email) != null) { AddErrors("Email already exists"); return(View(model)); } var createdUser = UserRepository.Create(objUser); if (createdUser != null) { // Send an email with this link var callbackUrl = Url.Action("ConfirmEmail", "Account", new { token = CryptoEngine.Encrypt(createdUser.UserID.ToString()) }, protocol: Request.Url.Scheme); MailHelper.MailSend (new MailMessageHelper { Body = "Please confirm your email by copy past link in browser : " + callbackUrl + "", Subject = "Confirmation Mail", To = createdUser.Email }); return(RedirectToAction("RegistrationComplete", "Account")); } else { AddErrors(VTSConstants.Error); } } // If we got this far, something failed, redisplay form return(View(model)); }