コード例 #1
0
        public ActionResult Users_Create([DataSourceRequest]DataSourceRequest request, User user)
        {
            if (this.ModelState.IsValid)
            {
                var entity = new User
                {
                    FirstName = user.FirstName,
                    LastName = user.LastName,
                    Position = user.Position,
                    CreatedOn = user.CreatedOn,
                    ModifiedOn = user.ModifiedOn,
                    IsDeleted = user.IsDeleted,
                    DeletedOn = user.DeletedOn,
                    Email = user.Email,
                    EmailConfirmed = user.EmailConfirmed,
                    PasswordHash = user.PasswordHash,
                    SecurityStamp = user.SecurityStamp,
                    PhoneNumber = user.PhoneNumber,
                    PhoneNumberConfirmed = user.PhoneNumberConfirmed,
                    TwoFactorEnabled = user.TwoFactorEnabled,
                    LockoutEndDateUtc = user.LockoutEndDateUtc,
                    LockoutEnabled = user.LockoutEnabled,
                    AccessFailedCount = user.AccessFailedCount,
                    UserName = user.UserName
                };

                this.db.Users.Add(entity);
                this.db.SaveChanges();
                user.Id = entity.Id;
            }

            return this.Json(new[] { user }.ToDataSourceResult(request, this.ModelState));
        }
コード例 #2
0
        protected override IAsyncResult BeginExecute(RequestContext requestContext, AsyncCallback callback, object state)
        {
            var userName = requestContext.HttpContext.User.Identity.Name;
            this.UserProfile = this.Users.GetByName(userName);

            return base.BeginExecute(requestContext, callback, state);
        }
コード例 #3
0
 private void UpdateUserSettings(User model, ProfileViewModel viewModel)
 {
     model.UserName = viewModel.Email;
     model.FirstName = viewModel.FirstName;
     model.LastName = viewModel.LastName;
     model.Email = viewModel.Email;
     model.Position = viewModel.Position;
 }
コード例 #4
0
 public int CountProductsByUser(User user)
 {
     if (user.Organization.IsSupplier)
     {
         return this.products.All().Count(p => p.SupplierId == user.OrganizationId);
     }
     else
     {
         return user.Organization.Partners.Sum(s => s.Products.Count());
     }
 }
コード例 #5
0
 public int CountPurchaseByClient(User user)
 {
     if (user.Organization.IsSupplier)
     {
         return this.orders.All().Count(o => o.SupplierId == user.OrganizationId);
     }
     else
     {
         return this.orders.All().Count(o => o.ClientId == user.OrganizationId);
     }
 }
コード例 #6
0
 public int CountAllPartners(User user)
 {
     return this.organizations.GetById(user.OrganizationId).Partners.Count();
 }
コード例 #7
0
        public async Task<ActionResult> ExternalLoginConfirmation(ExternalLoginConfirmationViewModel model, string returnUrl)
        {
            if (this.User.Identity.IsAuthenticated)
            {
                return this.RedirectToAction("Index", "Manage");
            }

            if (this.ModelState.IsValid)
            {
                // Get the information about the user from the external login provider
                var info = await this.AuthenticationManager.GetExternalLoginInfoAsync();
                if (info == null)
                {
                    return this.View("ExternalLoginFailure");
                }

                var user = new User { UserName = model.Email, Email = model.Email };
                var result = await this.UserManager.CreateAsync(user);
                if (result.Succeeded)
                {
                    result = await this.UserManager.AddLoginAsync(user.Id, info.Login);
                    if (result.Succeeded)
                    {
                        await this.SignInManager.SignInAsync(user, isPersistent: false, rememberBrowser: false);
                        return this.RedirectToLocal(returnUrl);
                    }
                }

                this.AddErrors(result);
            }

            this.ViewBag.ReturnUrl = returnUrl;
            return this.View(model);
        }