예제 #1
0
        public void RegisterMemberWithoutDisplayName()
        {
            // Generate a random email address
            userName      = Guid.NewGuid().ToString().Replace("-", "_");
            emailAddress += userName + "@test.com";

            try
            {
                var member = new MemberVm()
                {
                    Email    = emailAddress,
                    Password = "******",
                    Username = userName
                };

                var dbMember = MemberSvc.CreateWithApplication(Manager.Id, member);

                _member        = dbMember.Member;
                _memberOptions = dbMember.Options;
                _memberLogin   = dbMember.Login;

                Assert.AreEqual(MemberManagerMessages.Error.MEMBER_DISPLAY_NAME_REQUIRED, dbMember.Message);
            }
            catch (Exception e)
            {
                Assert.AreEqual(MemberManagerMessages.Error.MEMBER_DISPLAY_NAME_REQUIRED, e.Message);
            }
        }
예제 #2
0
        public JsonResult GetDetails(Int64 id)
        {
            var res     = memberManager.GetById(id);
            var resText = new MemberVm
            {
                Id               = res.Id,
                Name             = res.Name,
                DepartmentId     = res.DepartmentId,
                CompanyListId    = res.CompanyListId,
                RankListId       = res.RankListId,
                Mobile           = res.Mobile,
                EmergencyMobile  = res.EmergencyMobile,
                Address          = res.Address,
                Email            = res.Email,
                Designation      = res.Designation,
                EntryDate        = res.EntryDate,
                RegistrationDate = res.RegistrationDate,
                JoiningDate      = res.JoiningDate,
                WhomEmployee     = res.WhomEmployee,
                RegistrationNo   = res.RegistrationNo,
                Status           = res.Status
            };

            return(Json(new { Data = resText, status = res == null ? false : true }, JsonRequestBehavior.AllowGet));
        }
예제 #3
0
        /// <summary>
        /// Update specific Member record
        /// </summary>
        /// <param name="id">Member Manager Id</param>
        /// <param name="view">Member View Model</param>
        /// <returns></returns>
        public (MemberVm member, bool IsSuccess, string Message) UpdateMember(int id, MemberVm view)
        {
            string errorMessage = String.Empty;

            var results = CheckUpdateRestrictions(id, view, out errorMessage);

            if (!results.Allow)
            {
                return(null, false, errorMessage);
            }

            // Update the member

            var dbMember = DataAccess.Member.GetById(view.Id);

            dbMember = view.ToEntity(dbMember);
            DataAccess.Member.Update(dbMember);

            // Save transaction.
            DataAccess.Save();

            var member = new MemberVm(dbMember);

            return(member, true, MemberManagerMessages.Success.MEMBER_UPDATE);
        }
        public ActionResult Delete(MemberVm vm)
        {
            try
            {
                // we first check if the member doesnt have any active loans
                // else the user needs to end these loans first
                var memberToCheckForLoans = _memberService.FindMember(vm.Id);
                var activeLoans           = false;

                foreach (var loan in memberToCheckForLoans.Loans)
                {
                    if (loan.ReturnDate < loan.StartDate)
                    {
                        activeLoans = true;
                        break;
                    }
                }
                if (activeLoans == true)
                {
                    return(RedirectToAction(nameof(Delete), new { id = vm.Id, blockDelete = true }));
                }

                _memberService.DeleteMember(vm.Id);
                return(RedirectToAction(nameof(Index)));
            }
            catch (DbException)
            {
                return(View());
            }
        }
        internal virtual MemberVm ToMemberVm(MemberVm view)
        {
            view.Email       = Email;
            view.DisplayName = DisplayName;
            view.Metadata    = Metadata;

            return(view);
        }
예제 #6
0
 internal MemberResponse(MemberVm m)
 {
     DisplayName = m.DisplayName;
     Email       = m.Email;
     Username    = m.Username;
     ProviderKey = m.ProviderKey;
     Metadata    = m.Metadata;
 }
        public ActionResult Index()
        {
            var vm = new MemberVm();

            vm.Members = _memberService.GetAllmembers();

            return(View(vm));
        }
 public void SelectMember(Guid id)
 {
     if (members.All(memberVm => memberVm.Id != id))
     {
         return;
     }
     {
         SelectedMember = members.SingleOrDefault(memberVm => memberVm.Id == id);
         SelectedMemberChanged?.Invoke(this, null);
     }
 }
        internal virtual MemberVm ToMemberVm()
        {
            var view = new MemberVm();

            view.Username    = Username;
            view.Password    = Password;
            view.Email       = Email;
            view.DisplayName = DisplayName;
            view.Metadata    = Metadata;

            return(view);
        }
예제 #10
0
        public MemberCreateResponse(MemberVm member, MemberLoginVm login)
        {
            ProviderKey = login.ProviderKey;
            Status      = login.Status;

            Username    = member.Username;
            Email       = member.Email;
            DisplayName = member.DisplayName;
            Metadata    = member.Metadata;

            CreateDate = member.CreateDate;
        }
예제 #11
0
        public async Task <MemberResponse> GetMemberDetails(MemberVm memberVm)
        {
            MemberResponse memberResponse = new MemberResponse();

            try
            {
                await _memberRepository.GetMemberDetails(memberVm);
            }
            catch (Exception ex)
            {
            }
            return(memberResponse);
        }
        public static CreateMemberCommand ToCreateMemberCommand(this MemberVm model)
        {
            var command = new CreateMemberCommand()
            {
                FirstName = model.FirstName,
                LastName  = model.LastName,
                Roles     = model.Roles,
                Avatar    = model.Avatar,
                Email     = model.Email
            };

            return(command);
        }
예제 #13
0
        public async Task <MemberVm> GetMemberDetails(MemberVm memberVm)
        {
            MemberVm memberVM = new MemberVm();

            try
            {
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            return(memberVM);
        }
        public void SelectMember(Guid id)
        {
            if (_members.Any(memberVm => memberVm.Id == id))
            {
                SelectedMember = _members.SingleOrDefault(memberVm => memberVm.Id == id);
            }
            else
            {
                SelectedMember = new MemberVm();
            }

            SelectedMemberChanged?.Invoke(this, null);
        }
        public ActionResult Edit(int id)
        {
            if (id == 0)
            {
                return(NotFound());
            }

            var vm = new MemberVm
            {
                Member = _memberService.FindMember(id)
            };

            return(View(vm));
        }
예제 #16
0
        public static UpdateMemberCommand ToUpdateMemberCommand(this MemberVm model)
        {
            var command = new UpdateMemberCommand
            {
                Id        = model.Id,
                FirstName = model.FirstName,
                LastName  = model.LastName,
                Roles     = model.Roles,
                Avatar    = model.Avatar,
                Email     = model.Email
            };

            return(command);
        }
예제 #17
0
 public static FamilyMember Map(this MemberVm model)
 {
     if (model == null)
     {
         return(null);
     }
     return(new FamilyMember
     {
         id = model.Id,
         avtar = model.Avatar,
         email = model.Email,
         firstname = model.FirstName,
         lastname = model.LastName,
         role = model.Roles
     });
 }
예제 #18
0
        public async Task <GetMemberQueryResult> GetMemberQueryHandler(Guid id)
        {
            MemberVm vm = new MemberVm();

            var member = await _memberRepository.ByIdAsync(id);

            if (member != null)
            {
                vm = _mapper.Map <MemberVm>(member);
            }

            return(new GetMemberQueryResult()
            {
                Payload = vm
            });
        }
        public ActionResult Create(MemberVm vm)
        {
            try
            {
                var newMember = new Member();

                newMember.SSN  = vm.SSN;
                newMember.Name = vm.Name;
                _memberService.AddMember(newMember);
                return(RedirectToAction(nameof(Index)));
            }
            catch (DbException)
            {
                return(View());
            }
        }
예제 #20
0
 public void SelectMember(Guid id)
 {
     if (members.All(memberVm => memberVm.Id != id))
     {
         SelectedMember = new MemberVm()
         {
             Id = Guid.Empty
         }
     }
     ;
     else
     {
         SelectedMember = members.SingleOrDefault(memberVm => memberVm.Id == id);
     }
     SelectedMemberChanged?.Invoke(this, null);
 }
        public ActionResult Edit(MemberVm vm)
        {
            try
            {
                var memberToUpdate = new Member();

                memberToUpdate.Id   = vm.Id;
                memberToUpdate.Name = vm.Name;
                memberToUpdate.SSN  = vm.SSN;

                _memberService.UpdateMember(memberToUpdate);
                return(RedirectToAction(nameof(Index)));
            }
            catch (DbException)
            {
                return(View());
            }
        }
예제 #22
0
        public async Task <GetMemberDetailsQueryResult> GetMemberByIDQueryHandler(Guid id)
        {
            MemberVm vm = new MemberVm();

            var members = await _memberRepository.Reset().ToListAsync();

            var result = members.First(a => a.Id == id);

            if (result != null)
            {
                vm = _mapper.Map <MemberVm>(result);
            }

            return(new GetMemberDetailsQueryResult()
            {
                Payload = vm
            });
        }
        public ActionResult Delete(int id, bool blockDelete)
        {
            if (id == 0)
            {
                return(NotFound());
            }

            var vm = new MemberVm
            {
                Member = _memberService.FindMember(id)
            };

            if (blockDelete)
            {
                vm.BlockDelete = true;
            }

            return(View(vm));
        }
        public IActionResult Submit(MemberVm member)
        {
            switch (member.ViewMode.ToLower())
            {
            case "edit":
                //do something
                break;

            case "add":
                //do something
                break;

            default:
                //do nothing
                break;
            }

            return(RedirectToAction("View", member));
        }
예제 #25
0
        public void ExistingUsernameValidation()
        {
            var member = new MemberVm()
            {
                Email    = emailAddress,
                Password = "******",
                Username = userName
            };

            try
            {
                var dbMember = MemberSvc.CreateWithApplication(Manager.Id, member);
                Assert.AreEqual(MemberManagerMessages.Error.USERNAME_EXISTS, dbMember.Message);
            }
            catch (Exception e)
            {
                Assert.AreEqual(e.Message, MemberManagerMessages.Error.USERNAME_EXISTS);
            }
        }
        public async Task CreateMember(MemberVm model)
        {
            var result = await Create(model.ToCreateMemberCommand());

            if (result != null)
            {
                var updatedList = (await GetAllMembers()).Payload;

                if (updatedList != null)
                {
                    members = updatedList;
                    MembersChanged?.Invoke(this, null);
                    return;
                }
                CreateMemberFailed?.Invoke(this, "The creation was successful, but we can no longer get an updated list of members from the server.");
            }

            CreateMemberFailed?.Invoke(this, "Unable to create record.");
        }
예제 #27
0
 /// <summary>
 /// Selects the member.
 /// </summary>
 /// <param name="id">The identifier.</param>
 public void SelectMember(Guid id)
 {
     if (members.All(memberVm => memberVm.Id != id && id != Guid.Empty))
     {
         return;
     }
     {
         if (id == Guid.Empty)
         {
             SelectedMember = new MemberVm {
                 Id = id
             };
         }
         else
         {
             SelectedMember = members.SingleOrDefault(memberVm => memberVm.Id == id);
         }
         SelectedMemberChanged?.Invoke(this, null);
     }
 }
        public async Task UpdateMember(MemberVm model)
        {
            var result = await Update(model.ToUpdateMemberCommand());

            Console.WriteLine(JsonSerializer.Serialize(result));

            if (result != null)
            {
                var updatedList = (await GetAllMembers()).Payload;

                if (updatedList != null)
                {
                    members = updatedList;
                    MembersChanged?.Invoke(this, null);
                    return;
                }
                UpdateMemberFailed?.Invoke(this, "The save was successful, but we can no longer get an updated list of members from the server.");
            }

            UpdateMemberFailed?.Invoke(this, "Unable to save changes.");
        }
예제 #29
0
        public void RegisterMember()
        {
            // Generate a random email address
            userName      = Guid.NewGuid().ToString().Replace("-", "_");
            emailAddress += userName + "@test.com";

            var member = new MemberVm()
            {
                Email       = emailAddress,
                Password    = "******",
                DisplayName = "Sam Sample",
                Username    = userName
            };

            var dbMember = MemberSvc.CreateWithApplication(Manager.Id, member);

            _member        = dbMember.Member;
            _memberOptions = dbMember.Options;
            _memberLogin   = dbMember.Login;

            Assert.AreNotEqual(_member.Id, 0);
        }
예제 #30
0
        public async Task <GetAllMemberTasksQueryResult> GetAllMemberTasksQueryHandler()
        {
            var tasks = await _taskRepository.Reset().ToListAsync();

            List <MemberTasksVm> vdm = new List <MemberTasksVm>();

            if (tasks != null && tasks.Any())
            {
                foreach (var data in tasks)
                {
                    MemberTasksVm res = new MemberTasksVm();
                    res.Id           = data.Id;
                    res.AssignedToId = data.AssignedToId;
                    res.IsComplete   = data.IsComplete;
                    res.Subject      = data.Subject;
                    var members = await _memberRepository.Reset().ToListAsync();

                    var      result = members.First(a => a.Id == res.AssignedToId);
                    MemberVm mem    = new MemberVm();
                    mem.Avatar    = result.Avatar;
                    mem.Email     = result.Email;
                    mem.FirstName = result.FirstName;
                    mem.LastName  = result.LastName;
                    mem.Roles     = result.Roles;
                    res.Members   = mem;
                    vdm.Add(res);
                }
            }
            IEnumerable <MemberTasksVm> vm = new List <MemberTasksVm>();

            vm = vdm;
            //vm = _mapper.Map<IEnumerable<MemberTasksVm>>(tasks);

            return(new GetAllMemberTasksQueryResult()
            {
                Payload = vm
            });
        }