예제 #1
0
        public async Task RegisterAsync(MemberAddModel member)
        {
            using (var apiClient = GetClient())
            {
                var response = await apiClient.PostAsJsonAsync("Registration", member);

                response.EnsureSuccessStatusCode();
            }
        }
예제 #2
0
        public ActionResult Add(MemberAddModel m)
        {
            if (Members.GmailExists(m.Gmail))
            {
                return(RedirectToAction("Add"));
            }

            Members.AddMember(m.Gmail, m.Password, m.Name, m.Surname, Int32.Parse(m.RoleIdString), m.Date);

            return(RedirectToAction("AllMembers"));
        }
예제 #3
0
        public async Task <IResultModel> Add(MemberAddModel model)
        {
            var entity = _mapper.Map <MemberEntity>(model);
            //if (await _repository.Exists(entity))
            //{
            //return ResultModel.HasExists;
            //}
            var result = await _repository.AddAsync(entity);


            return(ResultModel.Result(result));
        }
예제 #4
0
        private async Task LoginToForumAsync(LoginViewModel model)
        {
            var user      = UserManager.FindByName(model.UserName);
            var forumUser = await _forumService.GetUserAsync(user.Id);

            if (forumUser == null)
            {
                var memberModel = new MemberAddModel
                {
                    UserName    = model.UserName,
                    Email       = user.Email,
                    IsApproved  = true,
                    Password    = model.Password,
                    UniversalId = user.Id,
                    //Need to map responder somehow
                };

                await _forumService.RegisterAsync(memberModel);
            }
        }
예제 #5
0
        public async Task <IActionResult> Add(MemberAddModel model)
        {
            if (ModelState.IsValid)
            {
                Member member = new Member();
                member.Name = model.Name;
                await _context.Members.AddAsync(member);

                List <Language> languages = await _context.Languages.ToListAsync();

                for (int i = 0; i < languages.Count; i++)
                {
                    if (model.Positions[i] != null)
                    {
                        MemberLanguage memberLanguage = new MemberLanguage()
                        {
                            MemberId   = member.Id,
                            Position   = model.Positions[i],
                            LanguageId = languages[i].Id
                        };
                        await _context.MemberLanguages.AddAsync(memberLanguage);
                    }
                }

                foreach (string file in model.Photos)
                {
                    member.Photo = file;
                }

                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            else
            {
                return(RedirectToAction(nameof(Add)));
            }
        }
예제 #6
0
        public async Task <IActionResult> Edit(MemberAddModel model, int memberId)
        {
            if (!model.Positions.IsNull() && model.Name != null)
            {
                Member member = await _context.Members.Where(s => s.Id == memberId).FirstOrDefaultAsync();

                member.Name = model.Name;
                List <Language> languages = await _context.Languages.ToListAsync();

                for (int i = 0; i < languages.Count; i++)
                {
                    MemberLanguage MemberLanguage = await _context.MemberLanguages
                                                    .Where(sl => sl.MemberId == memberId &&
                                                           sl.LanguageId == languages[i].Id)
                                                    .FirstOrDefaultAsync();

                    if (MemberLanguage == null)
                    {
                        MemberLanguage = new MemberLanguage()
                        {
                            MemberId   = memberId,
                            LanguageId = languages[i].Id,
                            Position   = model.Positions[i],
                        };

                        await _context.MemberLanguages.AddAsync(MemberLanguage);
                    }
                    else
                    {
                        MemberLanguage.Position = model.Positions[i];
                    }
                }

                if (!model.DeletePhotos.IsNull() && !model.DeletePhotos.IsNullOrEmpty())
                {
                    foreach (string deletePhoto in model.DeletePhotos)
                    {
                        if (member.Photo == deletePhoto)
                        {
                            string path = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot", "Uploads", "Members", deletePhoto);
                            if (System.IO.File.Exists(path))
                            {
                                System.IO.File.Delete(path);
                            }
                            member.Photo = null;
                        }
                    }
                }

                if (!model.Photos.IsNull() && !model.Photos.IsNullOrEmpty())
                {
                    foreach (string addPhoto in model.Photos)
                    {
                        member.Photo = addPhoto;
                    }
                }

                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(RedirectToAction(nameof(Edit)));
        }
예제 #7
0
 public Task <IResultModel> Add(MemberAddModel model)
 {
     return(_service.Add(model));
 }