示例#1
0
        public async Task <ActionResult> CreateHouseholdMember(CreateMemberViewModel model)
        {
            if (ModelState.IsValid)
            {
                var currentUserHId = User.Identity.GetHouseholdId();
                var user           = new ApplicationUser {
                    UserName = model.Email, Email = model.Email, FirstName = model.FirstName,
                    LastName = model.LastName, HouseholdId = currentUserHId
                };
                //if (user.UserName == ApplicationUser.Any
                var result = await UserManager.CreateAsync(user);

                if (result.Succeeded)
                {
                    await InviteToJoin(user);



                    // 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("CreateHouseholdMemberConfirmation"));
                }
                AddErrors(result);
            }
            // If we got this far, something failed, redisplay form
            return(View(model));
        }
示例#2
0
        public IActionResult CreateMember(int familyId)
        {
            var model = new CreateMemberViewModel();

            model.FamilyId = familyId;
            return(View(model));
        }
        public async Task <IActionResult> Create()
        {
            var viewModel = new CreateMemberViewModel();

            viewModel.MembershipTypes = await GetMembershipTypes("Välj typ av medlemskap");

            return(View(viewModel));
        }
示例#4
0
        public async Task InsertAsync(CreateMemberViewModel model)
        {
            var member = memberRepository.GetInstance();

            member = model.Member;
            memberRepository.Insert(member);
            await unitOfWork.CommitAsync();
        }
        public IActionResult Create()
        {
            var model = new CreateMemberViewModel();

            model.Faculties = _facultyRepository.GetList();

            return(View(model));
        }
示例#6
0
        public RedirectToRouteResult Create(CreateMemberViewModel viewModel)
        {
            var model = viewModel.Member;

            _createMemberCommand.Execute(model);

            return(RedirectToAction("index", "Member"));
        }
示例#7
0
        public async Task <IActionResult> _Update(Guid id, CreateMemberViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(Alert.ErrorInInputParameter.GetMessage()));
            }

            await memberService.UpdateAsync(id, model);

            return(Ok());
        }
示例#8
0
 public async Task <IActionResult> _Create(CreateMemberViewModel model)
 {
     if (!ModelState.IsValid)
     {
         return(BadRequest(Alert.ErrorInInputParameter.GetMessage()));
     }
     if (model.Member.Id != null)
     {
         await memberService.InsertAsync(model);
     }
     return(Ok(Alert.SuccessInsert.GetMessage()));
 }
示例#9
0
 public Member(CreateMemberViewModel vm)
 {
     PersonalNumber = vm.PersonalNumber;
     FirstName      = vm.FirstName;
     LastName       = vm.LastName;
     Address        = vm.Address;
     PostalCode     = vm.PostalCode;
     City           = vm.City;
     Email          = vm.Email;
     Phone          = vm.Phone;
     JoinDate       = DateTime.Today;
 }
        public CreateMemberViewModel Create()
        {
            var categories = _categoriesListQuery.Execute();

            var viewModel = new CreateMemberViewModel();

            viewModel.Categories = categories
                                   .Select(x => new SelectListItem()
            {
                Value = x.Id.ToString(),
                Text  = x.Name
            })
                                   .ToList();

            viewModel.Member = new CreateMemberModel();

            return(viewModel);
        }
        public IActionResult Create(CreateMemberViewModel model)
        {
            if (ModelState.IsValid)
            {
                int?facultyId,
                   groupId;

                if (model.FacultyId == 0)
                {
                    facultyId = null;
                }
                else
                {
                    facultyId = model.FacultyId;
                }

                if (model.GroupId == 0)
                {
                    groupId = null;
                }
                else
                {
                    groupId = model.GroupId;
                }

                Member member = new Member
                {
                    Name           = model.Name,
                    Surname        = model.Surname,
                    Patronymic     = model.Patronymic,
                    DateOfEntry    = model.DateOfEntry,
                    IsScholarship  = model.IsScholarship,
                    FacultyId      = facultyId,
                    GroupId        = groupId,
                    NumberOfTicket = model.NumberOfTicket
                };
                _membersRepository.Create(member);

                return(RedirectToAction("index", "home"));
            }

            return(RedirectToAction("create"));
        }
示例#12
0
        public ActionResult CreateMember(CreateMemberViewModel model)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    service.VerifyInitializer(model.InlinerID);
                    var member = service.CreateMember(model);
                    service.CollectMember(member);

                    return(RedirectToAction("Index"));
                }
                catch (CustomException ex)
                {
                    ModelState.AddModelError("InlinerID", ex.Message);
                }
            }
            return(View());
        }
        public ActionResult Create(CreateMemberViewModel model)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    Member newMember = new Member();
                    newMember.VillageName = model.VillageName;

                    MembersManager.Add(newMember);
                }
            }
            catch
            {
                return View(new CreateMemberViewModel());
            }

            return RedirectToAction("Index");
        }
示例#14
0
        internal Member CreateMember(CreateMemberViewModel model)
        {
            var member = new Member();

            using (var trans = context.Database.BeginTransaction())
            {
                context.ApplyLock <Member>();
                var distriID = CreateId();
                while (true)
                {
                    if (context.Members.Any(x => x.DistributerID == distriID))
                    {
                        distriID = CreateId();
                    }
                    else
                    {
                        var user = new ApplicationUser()
                        {
                            Email = model.Email, UserName = distriID
                        };
                        _userManager.Create(user);
                        var roleID = roleManager.FindByName(Roles.Customer).Id;
                        user.Roles.Add(new IdentityUserRole {
                            RoleId = roleID, UserId = user.Id
                        });
                        member.DistributerID = distriID;
                        member.User          = user;
                        member.FirstName     = model.FirstName;
                        member.LastName      = model.LastName;
                        member.IsActive      = true;
                        member.MaxValue      = model.MaximumAmount;
                        member.UplineId      = context.Members.AsNoTracking().Single(x => x.DistributerID == model.InlinerID).MemberID;
                        context.Members.Add(member);
                        context.Commit();
                        trans.Commit();
                        break;
                    }
                }
            }
            return(member);
        }
        public async Task <IActionResult> Create(CreateMemberViewModel viewModel)
        {
            if (ModelState.IsValid)
            {
                var membershipType = await _db.MembershipTypes.FindAsync((int)viewModel.MembershipTypeId);

                var member = new Member(viewModel);

                member.ExpireDate = member.JoinDate.AddYears(membershipType.LengthInYears);

                await _db.AddAsync(member);

                await _db.SaveChangesAsync();

                TempData["Message"] = "Medlem registrerad!";
                return(RedirectToAction("Index"));
            }
            viewModel.MembershipTypes = await GetMembershipTypes("Välj typ av medlemskap");

            return(View(viewModel));
        }
示例#16
0
        public async Task <IActionResult> CreateMember(CreateMemberViewModel model)
        {
            if (ModelState.IsValid)
            {
                var user = new ApplicationUser {
                    UserName = model.Email, Email = model.Email
                };

                var family = await _familyService.GetByIdAsync(model.FamilyId);

                if (family != null)
                {
                    user.Family = family;
                }

                var result = await _userManager.CreateAsync(user, model.Password);

                if (result.Succeeded)
                {
                    //_logger.LogInformation("User created a new account with password.");

                    var code = await _userManager.GenerateEmailConfirmationTokenAsync(user);

                    var callbackUrl = Url.EmailConfirmationLink(user.Id, code, Request.Scheme);
                    await _emailSender.SendEmailConfirmationAsync(model.Email, callbackUrl);

                    return(RedirectToAction("Edit", new { id = model.FamilyId }));
                }
                else
                {
                    if (result.Errors != null && result.Errors.Count() > 0)
                    {
                        ViewData["Validation"] = String.Join(Environment.NewLine, result.Errors.Select(c => c.Description).ToArray());
                    }
                }
            }

            // If we got this far, something failed, redisplay form
            return(View(model));
        }
        public ActionResult Create(CreateMemberViewModel model)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    ClanUser newMember = new ClanUser();

                    newMember.name       = model.Name;
                    newMember.userRoleId = (short)ClanRole.Member;
                    newMember.clanId     = ClanManager.GetClanId(User.Identity.GetUserId());

                    ClanUserManager.Insert(newMember);
                }
            }
            catch
            {
                return(View(new CreateMemberViewModel()));
            }

            return(RedirectToAction("EditMode"));
        }
示例#18
0
 public async Task UpdateAsync(Guid id, CreateMemberViewModel model)
 {
     memberRepository.Update(model.Member);
     await unitOfWork.CommitAsync();
 }