public async Task<ActionResult> Add(NewUserVM user) { if (!ModelState.IsValid) { return View(user); } QueryResult<bool> exists = await _signalManager.CheckEmailExists(user.Email); if (exists.HasExceptions) { string message = string.Format(ViewContent.Common_DatabaseError, user.Email); ModelState.AddModelError("", message); return View(user); } if (exists.Result) { string message = string.Format(ViewContent.Users_Add_EmailExists, user.Email); ModelState.AddModelError("", message); return View(user); } bool addResult = await _signalManager.AddUser(user); if (!addResult) { string message = string.Format(ViewContent.Common_DatabaseError, user.Email); ModelState.AddModelError("", message); return View(user); } ViewBag.ResultMessage = ViewContent.Users_Add_AddSuccessful; return View(user); }
public async Task<bool> AddUser(NewUserVM user) { ObjectId userId = ObjectId.GenerateNewId(); var settings = UserDeliveryTypeSettings<ObjectId>.Default( userId, (int)DeliveryType.Console, user.Email, _language); settings.IsEnabled = user.IsEmailEnabled; bool deliveryResult = await _deliveryTypeQueries.Insert( new List<UserDeliveryTypeSettings<ObjectId>>() { settings }); if(!deliveryResult) { return false; } var catSettings = new UserCategorySettings<ObjectId>() { UserID = userId, DeliveryType = (int)DeliveryType.Console, CategoryID = (int)Category.Games, IsEnabled = true }; bool categoryResult = await _categoryQueries.Insert(new List<UserCategorySettings<ObjectId>>() { catSettings }); return categoryResult; }
public ActionResult Add() { NewUserVM user = new NewUserVM() { IsEmailEnabled = true }; return View(user); }