public NewThreadModel GetNewThreadModel(UserInt sender, UserInt receiver) { NewThreadModel model = new NewThreadModel(sender, receiver); model.Prepare(Title, Text); return(model); }
public async Task <IHttpActionResult> RegisterExternal(RegisterExternalBindingModel model) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var info = await Authentication.GetExternalLoginInfoAsync(); if (info == null) { return(InternalServerError()); } var user = new UserInt() { UserName = model.Email, Email = model.Email }; IdentityResult result = await UserManager.CreateAsync(user); if (!result.Succeeded) { return(GetErrorResult(result)); } result = await UserManager.AddLoginAsync(user.Id, info.Login); if (!result.Succeeded) { return(GetErrorResult(result)); } return(Ok()); }
public async Task <ActionResult> Register(RegisterViewModel model) { if (ModelState.IsValid) { var user = new UserInt { UserName = model.Email, Email = model.Email }; var result = await _userManager.CreateAsync(user, model.Password); if (result.Succeeded) { await _signInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false); // For more information on how to enable account confirmation and password reset please visit http://go.microsoft.com/fwlink/?LinkID=320771 // Send an email with this link // string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id); // var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme); // await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>"); return(RedirectToAction("Index", "Home")); } AddErrors(result); } // If we got this far, something failed, redisplay form return(View(model)); }
public IHttpActionResult Create(CreateModel model) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } UserInt user = UserIntFactory.CreateFromIdentity(_uow, User); Vehicle vehicle = model.GetVehicle(user); _uow.GetRepository <IVehicleRepository>().Add(vehicle); _uow.Commit(); _uow.RefreshAllEntities(); Blog blog = new Blog { Vehicle = vehicle, VehicleId = vehicle.VehicleId, AuthorId = user.Id, Name = vehicle.Make + " " + vehicle.Model // TODO :: ugly }; _uow.GetRepository <IBlogRepository>().Add(blog); _uow.Commit(); if (_userManager.IsInRole(User.Identity.GetUserId <int>(), "CarOwner") == false) { _userManager.AddToRole(User.Identity.GetUserId <int>(), "CarOwner"); } return(Ok(model)); }
public IHttpActionResult PutUserInt(int id, UserInt userInt) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != userInt.Id) { return(BadRequest()); } _uow.UsersInt.Update(userInt); try { _uow.Commit(); } catch (DbUpdateConcurrencyException) { if (_uow.UsersInt.GetById(id) != null) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public static DetailsModel CreateFromUserInt(UserInt user) { return(new DetailsModel() { id = user.Id, Email = user.Email, UserName = user.FirstLastName, // TODO :: this is empty, fix when creating a better registration MemberSinceDateTime = user.CreatedAt, }); }
private void CheckSenderAndReceiver(UserInt sender, UserInt receiver) { if (sender == null) { throw new ArgumentNullException(nameof(sender)); } if (receiver == null) { throw new ArgumentNullException(nameof(receiver)); } }
public IHttpActionResult PostUserInt(UserInt userInt) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _uow.UsersInt.Add(userInt); _uow.Commit(); return(CreatedAtRoute("DefaultApi", new { id = userInt.Id }, userInt)); }
// GET: MemberArea/Messages/Create public ActionResult Create(int?receiverId) { UserInt user = _uow.GetRepository <IUserIntRepository>().GetById(receiverId); if (user == null) { return(HttpNotFound()); } BLL.ViewModels.MessageThread.CreateModel createModel = new BLL.ViewModels.MessageThread.CreateModel(); return(View(createModel)); }
public Domain.Vehicle GetVehicle(UserInt creator) { Domain.Vehicle vehicle = new Domain.Vehicle { UserId = creator.Id, Engine = Engine, Kw = Kw, Year = Year, Model = Model, Make = System.Threading.Thread.CurrentThread.CurrentCulture.TextInfo.ToTitleCase(Make.Replace("-", " ")) }; return(vehicle); }
public ActionResult Edit( [Bind( Include = "Id,Email,EmailConfirmed,PasswordHash,SecurityStamp,PhoneNumber,PhoneNumberConfirmed,TwoFactorEnabled,LockoutEndDateUtc,LockoutEnabled,AccessFailedCount,UserName,FirstName,LastName" )] UserInt user) { if (ModelState.IsValid) { _uow.UsersInt.Update(user); _uow.Commit(); return(RedirectToAction("Index")); } return(View(user)); }
public async Task <ActionResult> Register(RegisterViewModel model) { if (ModelState.IsValid) { var user = new UserInt { UserName = model.Email, Email = model.Email, LastName = model.LastName, FirstName = model.FirstName }; var userSave = await _userManager.CreateAsync(user, model.Password); if (userSave.Succeeded == false) { AddErrors(userSave); } else { var webApiUOW = _uow as UOW; if (webApiUOW != null) { var token = webApiUOW.GetWebApiToken(model.Email, model.Password); var newUser = _userManager.FindByEmail(model.Email); if (newUser != null) { //remove any previous auth claims var claims = _userManager.GetClaims(newUser.Id).Where(c => c.Type == ClaimTypes.Authentication).ToList(); _logger.Debug($"Claimcount: {claims.Count}"); await _userManager.AddToRoleAsync(newUser.Id, "User"); // TODO :: fetch role and then add if exists foreach (var claim in claims) { _userManager.RemoveClaim(newUser.Id, claim); } _userManager.AddClaim(newUser.Id, new Claim(ClaimTypes.Authentication, token)); _signInManager.SignIn(newUser, true, true); } } // For more information on how to enable account confirmation and password reset please visit http://go.microsoft.com/fwlink/?LinkID=320771 // Send an email with this link // string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id); // var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme); // await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>"); return(RedirectToAction("Index", "Dashboard")); } } // If we got this far, something failed, redisplay form return(View("Register", "_Empty")); }
// GET: MemberArea/Profile/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } UserInt user = _uow.GetRepository <IUserIntRepository>().GetById(id); if (user == null) { return(HttpNotFound()); } return(View(DetailsModelFactory.CreateFromUserInt(user))); }
public ActionResult Create([Bind(Include = "Title,Text")] BLL.ViewModels.MessageThread.CreateModel createModel, int?receiverId) { UserInt user = _uow.GetRepository <IUserIntRepository>().GetById(receiverId); if (user == null && User.Identity.GetUserId <int>() != receiverId) { return(HttpNotFound()); } if (ModelState.IsValid) { UserInt sender = UserIntFactory.CreateFromIdentity(_uow, User); NewThreadModel newThreadModel = new NewThreadModel(sender, user); newThreadModel.Prepare(createModel.Title, createModel.Text); int id = _uow.GetRepository <IMessageThreadRepository>().Add(newThreadModel.MessageThread); _uow.Commit(); Message message = newThreadModel.Message; message.MessageThreadId = id; message.AuthorId = newThreadModel.MessageThread.AuthorId; message.Status = MessageStatus.New; int messageId = _uow.GetRepository <IMessageRepository>().Add(message); foreach (var messageReceiver in newThreadModel.MessageReceivers) { messageReceiver.MessageId = messageId; _uow.GetRepository <IMessageReceiverRepository>().Add(messageReceiver); } foreach (var messageThreadReceiver in newThreadModel.MessageThreadReceivers) { messageThreadReceiver.MessageThreadId = id; _uow.GetRepository <IMessageThreadReceiverRepository>().Add(messageThreadReceiver); } _uow.Commit(); return(RedirectToAction("Index")); } return(View(createModel)); }
public async Task <IHttpActionResult> Register(RegisterBindingModel model) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var user = new UserInt() { UserName = model.Email, Email = model.Email }; IdentityResult result = await UserManager.CreateAsync(user, model.Password); if (!result.Succeeded) { return(GetErrorResult(result)); } return(Ok()); }
public async Task <ActionResult> ExternalLoginConfirmation(ExternalLoginConfirmationViewModel model, string returnUrl) { if (User.Identity.IsAuthenticated) { return(RedirectToAction("Index", "Manage")); } if (ModelState.IsValid) { // Get the information about the user from the external login provider var info = await _authenticationManager.GetExternalLoginInfoAsync(); if (info == null) { return(View("ExternalLoginFailure")); } var user = new UserInt { UserName = model.Email, Email = model.Email }; var result = await _userManager.CreateAsync(user); if (result.Succeeded) { result = await _userManager.AddLoginAsync(user.Id, info.Login); if (result.Succeeded) { await _signInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false); return(RedirectToLocal(returnUrl)); } } AddErrors(result); } ViewBag.ReturnUrl = returnUrl; return(View(model)); }
public override async Task GrantResourceOwnerCredentials(OAuthGrantResourceOwnerCredentialsContext context) { var userManager = context.OwinContext.GetUserManager <ApplicationUserManager>(); UserInt user = await userManager.FindAsync(context.UserName, context.Password); if (user == null) { context.SetError("invalid_grant", "The user name or password is incorrect."); return; } ClaimsIdentity oAuthIdentity = await user.GenerateUserIdentityAsync(userManager, OAuthDefaults.AuthenticationType); ClaimsIdentity cookiesIdentity = await user.GenerateUserIdentityAsync(userManager, CookieAuthenticationDefaults.AuthenticationType); AuthenticationProperties properties = CreateProperties(user.UserName); AuthenticationTicket ticket = new AuthenticationTicket(oAuthIdentity, properties); context.Validated(ticket); context.Request.Context.Authentication.SignIn(cookiesIdentity); }
public async Task<ActionResult> ExternalLoginConfirmation(ExternalLoginConfirmationViewModel model, string returnUrl) { if (User.Identity.IsAuthenticated) { return RedirectToAction("Index", "Manage"); } if (ModelState.IsValid) { // Get the information about the user from the external login provider var info = await _authenticationManager.GetExternalLoginInfoAsync(); if (info == null) { return View("ExternalLoginFailure"); } var user = new UserInt {UserName = model.Email, Email = model.Email}; var result = await _userManager.CreateAsync(user); if (result.Succeeded) { result = await _userManager.AddLoginAsync(user.Id, info.Login); if (result.Succeeded) { await _signInManager.SignInAsync(user, isPersistent: false, rememberBrowser: false); return RedirectToLocal(returnUrl); } } AddErrors(result); } ViewBag.ReturnUrl = returnUrl; return View(model); }
public async Task<ActionResult> Register(RegisterViewModel model) { if (ModelState.IsValid) { var user = new UserInt {UserName = model.Email, Email = model.Email}; var result = await _userManager.CreateAsync(user, model.Password); if (result.Succeeded) { await _signInManager.SignInAsync(user, isPersistent: false, rememberBrowser: false); // For more information on how to enable account confirmation and password reset please visit http://go.microsoft.com/fwlink/?LinkID=320771 // Send an email with this link // string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id); // var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme); // await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>"); return RedirectToAction("Index", "Home"); } AddErrors(result); } // If we got this far, something failed, redisplay form return View(model); }
/* * Refer to explanation for CreateMenuItemValidator method for explanation. */ public void UpdateMenuValidator(string menuID, string name, string description, string price, string waitTimeMins, string ingredients, string calories, string halal, string catID, IFormFile file, IWebHostEnvironment hostEnvironment) { // INT VALIDATION int parsedMenuID; if (!int.TryParse(menuID, out parsedMenuID)) { throw new Exception("Menu ID must be a number"); } GetMenuItemByID(menuID); if (!string.IsNullOrWhiteSpace(price)) { double parsedPrice; if (!double.TryParse(price, out parsedPrice)) { throw new Exception("Price must be a number"); } if (!UserInt.IsPositiveNumber(parsedPrice)) { throw new Exception("Price can't be under $0"); } if (UserStr.IsLengthOverLimit(10, price)) { throw new Exception("Price connot be above 999999999"); } } int parsedWaitTime; if (!string.IsNullOrWhiteSpace(waitTimeMins)) { if (!int.TryParse(waitTimeMins, out parsedWaitTime)) { throw new Exception("Price must be a number"); } if (!UserInt.IsPositiveNumber(parsedWaitTime)) { throw new Exception("Wait time can't be under 0 minutes"); } if (UserStr.IsLengthOverLimit(10, waitTimeMins)) { throw new Exception("Wait Time connot be above 999999999 Minutes"); } } if (!string.IsNullOrWhiteSpace(calories)) { int parsedCalories; if (!int.TryParse(calories, out parsedCalories)) { throw new Exception("Calories must be a number"); } if (!UserInt.IsPositiveNumber(parsedCalories)) { throw new Exception("Calories can't be under 0 Calories. You wish"); } if (UserStr.IsLengthOverLimit(10, calories)) { throw new Exception("Calories connot be above 999999999 Calories"); } } if (!string.IsNullOrWhiteSpace(catID)) { int parsedCatID; if (!int.TryParse(catID, out parsedCatID)) { throw new Exception("Category ID must be a Number"); } } //BOOL VALIDATION bool parsedHalal; if (!string.IsNullOrWhiteSpace(halal)) { if (!bool.TryParse(halal, out parsedHalal)) { throw new Exception("Halal must be either true or false"); } } // STRING VALIDATION AND SANITIZATION if (!string.IsNullOrWhiteSpace(name)) { if (UserStr.IsLengthOverLimit(100, name)) { throw new Exception("Name cannot exceed 100 characters"); } } if (!string.IsNullOrWhiteSpace(description)) { if (UserStr.IsLengthOverLimit(1000, description)) { throw new Exception("Description cannot exceed 100 characters"); } } if (!string.IsNullOrWhiteSpace(ingredients)) { if (UserStr.IsLengthOverLimit(1000, ingredients)) { throw new Exception("Ingredients cannot exceed 100 characters"); } } UpdateMenuItem(menuID, name, description, price, waitTimeMins, ingredients, calories, halal, catID, file, hostEnvironment); }
/* * Menu Item methods/methods that interract with the menuitems table. * Seperated and ordered by CRUD functionalities. (Create, read, update, delete) */ // CREATE /* * Create Menu Validator validates all the data to make sure create menu item doesn't throw any exceptions. * This was necessary because Async methods return Task exceptions which not readable for humans. This method throws the exceptions before it gets to that. */ public void CreateMenuValidator(string name, string description, string price, string waitTimeMins, string ingredients, string calories, string halal, string catID, string resUsername, IFormFile file) { // INT VALIDATION if (string.IsNullOrWhiteSpace(price)) { throw new Exception("Price cannot be empty"); } double parsedPrice; if (!double.TryParse(price, out parsedPrice)) { throw new Exception("Price must be a number"); } if (!UserInt.IsPositiveNumber(parsedPrice)) { throw new Exception("Price can't be under $0"); } if (UserStr.IsLengthOverLimit(10, price)) { throw new Exception("Price connot be above 999999999"); } if (string.IsNullOrWhiteSpace(waitTimeMins)) { throw new Exception("Wait Time cannot be empty"); } int parsedWaitTime; if (!int.TryParse(waitTimeMins, out parsedWaitTime)) { throw new Exception("Price must be a number"); } if (!UserInt.IsPositiveNumber(parsedWaitTime)) { throw new Exception("Wait time can't be under 0 minutes"); } if (UserStr.IsLengthOverLimit(10, waitTimeMins)) { throw new Exception("Wait Time connot be above 999999999 Minutes"); } if (string.IsNullOrWhiteSpace(calories)) { throw new Exception("Calories cannot be empty"); } int parsedCalories; if (!int.TryParse(calories, out parsedCalories)) { throw new Exception("Calories must be a number"); } if (!UserInt.IsPositiveNumber(parsedCalories)) { throw new Exception("Calories can't be under 0 Calories. You wish"); } if (UserStr.IsLengthOverLimit(10, calories)) { throw new Exception("Calories connot be above 999999999 Calories"); } if (string.IsNullOrWhiteSpace(catID)) { throw new Exception("Category cannot be empty"); } int parsedCatID; if (!int.TryParse(catID, out parsedCatID)) { throw new Exception("Category ID must be a Number"); } //BOOL VALIDATION if (string.IsNullOrWhiteSpace(halal)) { throw new Exception("Restrictions cannot be empty"); } bool parsedHalal; halal = halal.ToLower().Trim(); if (!bool.TryParse(halal, out parsedHalal)) { throw new Exception("Halal must be either true or false"); } // STRING VALIDATION if (string.IsNullOrWhiteSpace(name)) { throw new Exception("Name cannot be empty"); } name = name.Trim(); if (UserStr.IsLengthOverLimit(100, name)) { throw new Exception("Name cannot exceed 100 characters"); } if (string.IsNullOrWhiteSpace(description)) { throw new Exception("Description cannot be empty"); } description = description.Trim(); if (UserStr.IsLengthOverLimit(1000, description)) { throw new Exception("Description cannot exceed 100 characters"); } if (string.IsNullOrWhiteSpace(ingredients)) { throw new Exception("Ingredients cannot be empty"); } ingredients = ingredients.Trim(); if (UserStr.IsLengthOverLimit(1000, ingredients)) { throw new Exception("Ingredients cannot exceed 100 characters"); } if (file == null) { throw new Exception("Must upload an image"); } RestaurantController.GetResByUsername(resUsername); CreateMenuItem(name, description, parsedPrice, parsedWaitTime, ingredients, parsedCalories, parsedHalal, parsedCatID, resUsername, file); }
public IUser CreateUser( string name, string password, string displayName, ID<IUserOrGroup, Guid> userId, bool builtIn, string identityProviderArgs, IIdentityProvider identityProvider) { name = name.ToLowerInvariant(); if (null != MaxLocalUsers) if (this.GetTotalLocalUsers() >= MaxLocalUsers.Value) throw new MaximumUsersExceeded("The maximum number of users allowed on this server is met: " + MaxLocalUsers.Value.ToString()); IDirectoryHandler usersDirectory = FileHandlerFactoryLocator.FileSystemResolver.ResolveFile("Users").CastFileHandler<IDirectoryHandler>(); IUserHandler newUser; IUser userObj = null; this.persistedUserManagerData.WriteReentrant(userManagerData => { this.ThrowExceptionIfDuplicate(userManagerData, name); if (identityProvider == FileHandlerFactoryLocator.LocalIdentityProvider) { if (usersDirectory.IsFilePresent(name)) throw new UserAlreadyExistsException("There is a pre-existing directory for " + name); if (usersDirectory.IsFilePresent(name + " .user")) throw new UserAlreadyExistsException("There is a pre-existing " + name + ".user"); } var user = new UserInt() { name = name, id = userId, builtIn = builtIn, displayName = displayName, identityProviderCode = identityProvider.IdentityProviderCode, identityProviderArgs = identityProviderArgs }; if (null != password) this.SetPassword(user, password); else { user.passwordMD5 = null; user.salt = null; } userManagerData.users[userId] = user; userManagerData.byName[name] = user; userObj = this.CreateUserObject(user); if (identityProvider == FileHandlerFactoryLocator.LocalIdentityProvider) { try { // Careful here!!! When calling the constructor of the user's .user object or the user's directory, a transaction will // be created against the user database! That can cause a deadlock! usersDirectory.CreateFile(name, "directory", userObj.Id); string userFileName = name + ".user"; newUser = usersDirectory.CreateSystemFile<IUserHandler>(userFileName, "user", userObj.Id); newUser.Name = name; usersDirectory.SetPermission( null, userFileName, new ID<IUserOrGroup, Guid>[] { FileHandlerFactoryLocator.UserFactory.Everybody.Id }, FilePermissionEnum.Read, false, false); } catch { if (null != usersDirectory) { if (usersDirectory.IsFilePresent(name)) try { usersDirectory.DeleteFile(null, name); } catch { } if (usersDirectory.IsFilePresent(name + ".user")) try { usersDirectory.DeleteFile(null, name + ".user"); } catch { } } throw; } if (!builtIn) this.CreateGroupInt( userManagerData, "friends", displayName + "'s friends", userObj.Id, new ID<IUserOrGroup, Guid>(Guid.NewGuid()), false, false, GroupType.Personal); } }); return userObj; }
/// <summary> /// Creates the user object /// </summary> /// <param name="userFromDB"></param> /// <returns></returns> private IUser CreateUserObject(UserInt user) { IIdentityProvider identityProvider = FileHandlerFactoryLocator.IdentityProviders[user.identityProviderCode]; IUser toReturn = identityProvider.CreateUserObject( FileHandlerFactoryLocator, user.id, user.name, user.builtIn, user.displayName, user.identityProviderArgs); return toReturn; }
public NewThreadModel(UserInt sender, UserInt receiver) { _sender = sender; _receiver = receiver; CheckSenderAndReceiver(sender, receiver); }
private void SetPassword(UserInt user, string password) { var rngCryptoServiceProvider = new RNGCryptoServiceProvider(); var salt = new byte[512]; rngCryptoServiceProvider.GetBytes(salt); user.salt = salt; user.passwordMD5 = UserManagerHandler.CreateMD5(password, salt); }
public async Task<IHttpActionResult> Register(RegisterBindingModel model) { if (!ModelState.IsValid) { return BadRequest(ModelState); } var user = new UserInt() {UserName = model.Email, Email = model.Email}; IdentityResult result = await UserManager.CreateAsync(user, model.Password); if (!result.Succeeded) { return GetErrorResult(result); } return Ok(); }
public List <UserPrivDTO> GetUserPrivPages(UserPrivDTO objPriv) { List <UserPriv> lstUserPriv = context.UserPrivs.Where(pp => pp.UserId.Equals(objPriv.UserId) && (objPriv.ViewId == -1 || pp.ViewId == objPriv.ViewId)).ToList(); List <UserPrivDTO> userPrivs = (from priv in lstUserPriv join view in context.ViewNames on priv.ViewId equals view.ViewId join interv in context.DivisionLists on priv.InterventionId equals interv.DivisionId into UserInt from intname in UserInt.DefaultIfEmpty() join headoff in context.OfficeLists on priv.HeadOfficeId equals headoff.OfficeID into userheadoff from headoffdef in userheadoff.DefaultIfEmpty() join cco in context.OfficeLists on priv.CCOId equals cco.OfficeID into Usercco from ccodef in Usercco.DefaultIfEmpty() join zone in context.OfficeLists on priv.ZoneId equals zone.OfficeID into Userzone from zonedef in Userzone.DefaultIfEmpty() join unit in context.OfficeLists on priv.UnitId equals unit.OfficeID into Userunit from unitdef in Userunit.DefaultIfEmpty() join area in context.OfficeLists on priv.AreaId equals area.OfficeID into Userarea from areadef in Userarea.DefaultIfEmpty() join bran in context.OfficeLists on priv.BranchId equals bran.OfficeID into Userbran from brandef in Userbran.DefaultIfEmpty() join dist in context.OfficeLists on priv.DistrictId equals dist.OfficeID into Userdist from distdef in Userdist.DefaultIfEmpty() join proj in context.ProjectLists on priv.ProjectId equals proj.ProjectId into Userproj from projdef in Userproj.DefaultIfEmpty() join grd in context.GradeLists on priv.GradeId equals grd.GradeId into Usergrd from grddef in Usergrd.DefaultIfEmpty() join sect in context.SectorLists on priv.SectorId equals sect.SectorId into Usersect from sectdef in Usersect.DefaultIfEmpty() select new UserPrivDTO() { ID = priv.ID, AreaId = priv.AreaId, BranchId = priv.BranchId, CCOId = priv.CCOId, DeletePerm = priv.DeletePerm, DistrictId = priv.DistrictId, GradeId = priv.GradeId, HeadOfficeId = priv.HeadOfficeId, InsertPerm = priv.InsertPerm, InterventionId = priv.InterventionId, InterventionName = intname == null ? "" : intname.DivisionName, HeadOfficeName = headoffdef == null ? "All" : headoffdef.OfficeTitle, CCOName = ccodef == null ? "All" : ccodef.OfficeTitle, ZoneName = zonedef == null ? "All" : zonedef.OfficeTitle, UnitName = unitdef == null ? "All" : unitdef.OfficeTitle, AreaName = areadef == null ? "All" : areadef.OfficeTitle, BranchName = brandef == null ? "All" : brandef.OfficeTitle, DistrictName = distdef == null ? "All" : distdef.OfficeTitle, ProjectName = projdef == null ? "All" : projdef.ProjectName, GradeName = grddef == null ? "All" : grddef.GradeName, SectorName = sectdef == null ? "All" : sectdef.SectorName, PageName = view.ViewName1, ProjectId = priv.ProjectId, SectorId = priv.SectorId, UnitId = priv.UnitId, UpazillaId = priv.UpazillaId, UserId = priv.UserId, ViewId = priv.ViewId, ViewPerm = priv.ViewPerm, ZoneId = priv.ZoneId }).ToList(); return(userPrivs); }
public async Task<IHttpActionResult> RegisterExternal(RegisterExternalBindingModel model) { if (!ModelState.IsValid) { return BadRequest(ModelState); } var info = await Authentication.GetExternalLoginInfoAsync(); if (info == null) { return InternalServerError(); } var user = new UserInt() {UserName = model.Email, Email = model.Email}; IdentityResult result = await UserManager.CreateAsync(user); if (!result.Succeeded) { return GetErrorResult(result); } result = await UserManager.AddLoginAsync(user.Id, info.Login); if (!result.Succeeded) { return GetErrorResult(result); } return Ok(); }