public ActionResult Signin1(UserCreateModel usersData, HttpPostedFileBase file) { if (ModelState.IsValid) { try { UserCreateHandler userCreateHandler = new UserCreateHandler(); UsersAddHandler usersAddHandler = new UsersAddHandler(); User user1 = usersAddHandler.Find(usersData.Email); if (user1 != null && user1.IsOwner) throw new ValidationException("Email", "Owner's Email already exists"); if (userCreateHandler.ExistsUserWithSameUserName(usersData.UserName)) throw new ValidationException("UserName", "Owner's UserName already exists"); string url = GetRandomString(20); //storing information about new user var user = Core.User.CreateOwner(usersData.FirstName, usersData.LastName, usersData.UserName, usersData.Password, usersData.Email, null, null, usersData.CountryId, null, 0, 0, null, 0, System.DateTime.Now, 1, 0, url, false, false, true, false, false); UsersAddHandler.Save(user); userCreateHandler.Handle(user); //Add path for new photo var path = "/Swisskip/" + user.UserName; if (!System.IO.Directory.Exists(Server.MapPath(path))) System.IO.Directory.CreateDirectory(Server.MapPath(path)); //Creating a default photo string newFile = Server.MapPath("/Content/images/") + user.UserName + ".jpg"; if (file != null) { file.SaveAs(newFile); } else { if (!System.IO.File.Exists(newFile)) System.IO.File.Copy(Server.MapPath("/Content/images/unknown.jpg"), Server.MapPath("/Content/images/") + user.UserName + ".jpg"); } //Link new owner with Trial Mode - Status=1 : new owner var user_userType1 = User_UserType.CreateRelationUserAndUserType(0, user.Id, (int)UserRoles.Owner, 0, System.DateTime.Now, 0, 0, 1); UsersAddHandler.Save(user_userType1); } catch (ValidationException e) { ModelState.AddModelError(e.Key, e.Message); return this.View(); } return RedirectToAction("MailVerification", "Authentication"); } return this.View(); }
public void SendConfirmationMail(UserCreateModel model) { var mailer = new DefaultMailer(); var msg = mailer.SendConfirmationMail(model.FirstName + "" + model.LastName, model.Email); msg.Send(); }