public MemberDto AddMember(NewMember newMember)
        {
            var member = new Member()
            {
                MemberId = newMember.MemberId,
                Name     = newMember.Name,
                Email    = newMember.Email,
                Mobile   = newMember.Mobile
            };

            var card = new Card()
            {
                CardId   = newMember.CardId,
                MemberId = newMember.MemberId,
                Pin      = newMember.Pin
            };

            if (members.TryAdd(member.MemberId, member) && cards.TryAdd(newMember.CardId, card))
            {
                return(new MemberDto {
                    Name = member.Name
                });
            }
            else
            {
                return(null);
            }
        }
Пример #2
0
        public async Task AddMember_Database_Call_Is_Made_Once()
        {
            // Arrange
            var cardId     = "ByDJ0lbYcPkzp2Ja";
            var memberRepo = new Mock <IMembershipRepository>();

            var newMember = new NewMember
            {
                CardId   = cardId,
                Name     = "Test User",
                MemberId = "1234",
                Email    = "*****@*****.**",
                Mobile   = "0774564154",
                Pin      = "3433"
            };

            var createdMember = new MemberDto()
            {
                Name = "Test User"
            };

            memberRepo.Setup(x => x.AddMember(It.IsAny <NewMember>())).Returns(() => null);

            // Act
            var memberService = new MemberService(memberRepo.Object);
            var result        = memberService.AddMember(newMember);

            // Assert
            memberRepo.Verify(x => x.AddMember(It.IsAny <NewMember>()), Times.Once);
        }
Пример #3
0
        public async Task AddMember_Controller_Action_Returns_Member_When_Created()
        {
            // Arrange
            var cardId = "ByDJ0lbYcPkzp2Ja";

            var newMember = new NewMember
            {
                CardId   = cardId,
                Name     = "Test User",
                MemberId = "1234",
                Email    = "*****@*****.**",
                Mobile   = "0774564154",
                Pin      = "3433"
            };

            var createdMember = new MemberDto()
            {
                Name = "Test User"
            };

            var memberService = new Mock <IMemberService>();

            memberService.Setup(x => x.AddMember(newMember)).Returns(createdMember);

            // Act
            var controller = new MemberController(memberService.Object);
            var result     = controller.AddMember(newMember);

            var resultMember = (CreatedAtActionResult)result;

            // Assert
            Assert.Equal(createdMember, resultMember.Value);
        }
Пример #4
0
        // GET: NewMembers/Delete/5
        public ActionResult Delete(string id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            NewMember newMember = db.NewMembers.Find(id);

            if (newMember == null)
            {
                return(HttpNotFound());
            }
            Session["PolicyNo"]        = newMember.policyNo;
            Session["title"]           = newMember.title;
            Session["fName"]           = newMember.fName;
            Session["lName"]           = newMember.lName;
            Session["IdNo"]            = newMember.IdNo;
            Session["dOb"]             = newMember.dOb;
            Session["age"]             = newMember.age;
            Session["gender"]          = newMember.gender;
            Session["maritalStat"]     = newMember.maritalStat;
            Session["telNo"]           = newMember.telNo;
            Session["cellNo"]          = newMember.cellNo;
            Session["CustEmail"]       = newMember.CustEmail;
            Session["fascimileNo"]     = newMember.fascimileNo;
            Session["physicalAddress"] = newMember.physicalAddress;
            Session["postalAddress"]   = newMember.postalAddress;
            Session["dateAdded"]       = newMember.dateAdded;
            Session["Policyplan"]      = newMember.Policyplan;
            Session["Premium"]         = newMember.Premium;
            Session["Category"]        = newMember.Category;
            return(View(newMember));
        }
        private void AddUpdateExpenses_Click(object sender, RoutedEventArgs e)
        {
            //tên thành viên
            Member MemberSelected = MembersComboBox.SelectedItem as Member;
            string membername     = MemberSelected.MemberName;
            ///tên khoản chi
            ReceiptsAndExpenses Expense = ExpendituresComboBox.SelectedItem as ReceiptsAndExpenses;
            string expensename          = Expense.ExpensesName;
            ///tiền cần update
            string cost = UpdateExpenseMoney.Text.Trim();

            Data = Main.DataContext as UpdateJourneyViewModel;
            if (membername != string.Empty && expensename != string.Empty && cost != string.Empty && Data != null)
            {
                trip.TripIsGoing();
                ReceiptsAndExpenses  receandexpen = new ReceiptsAndExpenses();
                IEnumerable <Member> NewMember;
                receandexpen.TripID = trip.TripID;


                NewMember = Data.MembersInComboBox.Where(i => i.MemberName.Contains(membername));

                receandexpen.MemberID = NewMember.ElementAt(0).MemberID;


                receandexpen.ExpensesName = expensename;

                receandexpen.Cost       = double.Parse(cost);
                UpdateExpenseMoney.Text = string.Empty;
                //thêm tên khoản chi vào bo nhớ tạm
                UpdateReceAndExpenlist.Add(receandexpen);
            }
        }
Пример #6
0
        public int AddKfcMember(int parentId, NewMember newMember)
        {
            using (var scope = new TransactionScope())
            {
                var dbMember = new DataModel.Generated.Member()
                {
                    FirstName = newMember.FirstName,
                    LastName  = newMember.LastName,
                    DOB       = newMember.DateOfBirth,
                    Gender    = newMember.Gender.ToString(),
                    Phone     = newMember.Phone,
                    Email     = newMember.Email,
                    MemberOf  = "KFC"
                };
                _unitOfWork.MemberRepository.Insert(dbMember);
                _unitOfWork.Save();

                var dbMemberMembership = new DataModel.Generated.MemberMembership()
                {
                    MemberId  = dbMember.MemberId,
                    MemberOf  = "KFC",
                    StartDate = DateTime.Now.Date
                };
                _unitOfWork.MemberMembershipRepository.Insert(dbMemberMembership);
                _unitOfWork.Save();
                scope.Complete();
                return(dbMember.MemberId);
            }
        }
        public ActionResult New(NewMember data)
        {
            if (!ModelState.IsValid)
            {
                Response.StatusCode = (int)HttpStatusCode.BadRequest;
                var modelErrors = ModelState.AllErrors();
                return(Json(modelErrors));
            }

            var newMember = new Member {
                Name  = data.Name,
                Email = data.Email
            };

            try
            {
                _context.Members.Add(newMember);
                _context.SaveChanges();
            }
            catch (UpdateException ex)
            {
                Exception currentException = ex;
                while (currentException != null)
                {
                    ModelState.AddModelError("EF", currentException.Message);
                    currentException = currentException.InnerException;
                }
                Response.StatusCode = (int)HttpStatusCode.InternalServerError;

                var modelErrors = ModelState.AllErrors();
                return(Json(modelErrors));
            }

            return(Json(JsonConvert.SerializeObject(newMember)));
        }
Пример #8
0
    public void SerializeObject(string filename)
    {
        // Create an instance of the XmlSerializer class.
        XmlSerializer mySerializer = CreateOverrider();
        // Writing the file requires a TextWriter.
        TextWriter writer = new StreamWriter(filename);

        // Create an instance of the class that will be serialized.
        Group myGroup = new Group();

        // Set the object properties.
        NewMember m = new NewMember();

        m.MemberName = "Paul";
        m.MemberID   = 2;

        // Create a second member.
        RetiredMember m2 = new RetiredMember();

        m2.MemberName = "Renaldo";
        m2.MemberID   = 23;
        m2.RetireDate = new DateTime(2000, 10, 10);

        myGroup.Members = new Member[2] {
            m, m2
        };

        // Serialize the class, and close the TextWriter.
        mySerializer.Serialize(writer, myGroup);
        writer.Close();
    }
Пример #9
0
 protected bool Check(NewMember x)
 {
     try {
         int    count = 0;
         string sql   = string.Format(@"SELECT COUNT(Id) FROM Members 
                     WHERE GroupId = {0} AND FirstName = '{1}' AND LastName = '{2}' AND ParentFirstName = '{3}' AND ParentLastName = '{4}'"
                                      , x.groupId, x.firstName, x.lastName, x.parentFirstName, x.parentLastName);
         using (SqlConnection connection = new SqlConnection(G.connectionString)) {
             connection.Open();
             using (SqlCommand command = new SqlCommand(sql, connection)) {
                 using (SqlDataReader reader = command.ExecuteReader()) {
                     while (reader.Read())
                     {
                         count = G.ReadI(reader, 0);
                     }
                 }
                 connection.Close();
             }
             if (count == 0)
             {
                 return(true);
             }
             else
             {
                 return(false);
             }
         }
     }
     catch (Exception e) { return(false); }
 }
Пример #10
0
    public List <NewMember> LoadData()
    {
        string           sql = @"SELECT m.Id, m.groupId, g.Club, g.GroupName, m.FirstName, m.LastName, m.BirthDate, m.isActive FROM Members m
                            LEFT OUTER JOIN Groups g
                            ON m.GroupId = g.Id
                            ORDER BY m.Id DESC";
        List <NewMember> xx  = new List <NewMember>();

        using (SqlConnection connection = new SqlConnection(G.connectionString)) {
            connection.Open();
            using (SqlCommand command = new SqlCommand(sql, connection)) {
                using (SqlDataReader reader = command.ExecuteReader()) {
                    while (reader.Read())
                    {
                        NewMember x = new NewMember();
                        x.id        = G.ReadI(reader, 0);
                        x.groupId   = G.ReadI(reader, 1);
                        x.club      = G.ReadS(reader, 2);
                        x.groupName = G.ReadS(reader, 3);
                        x.firstName = G.ReadS(reader, 4);
                        x.lastName  = G.ReadS(reader, 5);
                        x.birthDate = G.ReadS(reader, 6);
                        x.isActive  = G.ReadI(reader, 7);
                        xx.Add(x);
                    }
                }
            }
            connection.Close();
        }
        return(xx);
    }
Пример #11
0
        public int AddMember(NewMember newMember)
        {
            var gender = string.IsNullOrEmpty(newMember.Gender) ? (char?)null : newMember.Gender[0];

            using (var scope = new TransactionScope())
            {
                var dbMember = new DataModel.Generated.Member()
                {
                    FirstName      = newMember.FirstName,
                    LastName       = newMember.LastName,
                    DOB            = newMember.DateOfBirth,
                    Gender         = gender.ToString(),
                    Phone          = newMember.Phone,
                    Email          = newMember.Email,
                    SpouseMemberId = newMember.SpouseMemberId,
                    FatherMemberId = newMember.FatherMemberId,
                    MotherMemberId = newMember.MotherMemberId,
                    IsHeadOfFamily = newMember.IsHeadOfFamily
                };
                _unitOfWork.MemberRepository.Insert(dbMember);
                _unitOfWork.Save();

                if (newMember.SpouseMemberId.HasValue)
                {
                    var spouseMember =
                        _unitOfWork.MemberRepository.GetFirst(m => m.MemberId == newMember.SpouseMemberId.Value);
                    spouseMember.SpouseMemberId = dbMember.MemberId;
                    _unitOfWork.MemberRepository.Update(spouseMember);
                    _unitOfWork.Save();
                }
                scope.Complete();
                return(dbMember.MemberId);
            }
        }
Пример #12
0
 public Task AddNewMember(NewMember member)
 {
     return(Task.Factory.StartNew(() =>
     {
         database.SaveItem <NewMember>(member);
     }));
 }
Пример #13
0
        public int AddSpouseOfMember(int spouseMemberId, NewMember newMember)
        {
            using (var scope = new TransactionScope())
            {
                var dbMember = new DataModel.Generated.Member()
                {
                    FirstName      = newMember.FirstName,
                    LastName       = newMember.LastName,
                    DOB            = newMember.DateOfBirth,
                    Gender         = newMember.Gender.ToString(),
                    Phone          = newMember.Phone,
                    Email          = newMember.Email,
                    SpouseMemberId = spouseMemberId
                };
                _unitOfWork.MemberRepository.Insert(dbMember);
                _unitOfWork.Save();
                var newMemberId = dbMember.MemberId;

                var spouse = _unitOfWork.MemberRepository.Get(u => u.MemberId == spouseMemberId);
                spouse.SpouseMemberId = newMemberId;
                _unitOfWork.MemberRepository.Update(spouse);
                _unitOfWork.Save();

                scope.Complete();
                return(dbMember.MemberId);
            }
        }
Пример #14
0
        private void memberToolStripMenuItem_Click(object sender, EventArgs e)
        {
            RemoteSource member;
            NewMember    newMemberForm = new NewMember();

            newMemberForm.ShowDialog();
            if (newMemberForm.created)
            {
                new Thread((ThreadStart) delegate {
                    string resultFile = IBMiUtils.DownloadMember(newMemberForm._lib, newMemberForm._spf, newMemberForm._mbr, (newMemberForm._type == "*NONE" ? "" : newMemberForm._type));

                    if (resultFile != "")
                    {
                        member = new RemoteSource(resultFile, newMemberForm._lib, newMemberForm._spf, newMemberForm._mbr, newMemberForm._type, true);
                        //LOCK HERE
                        member.Lock();
                        this.Invoke((MethodInvoker) delegate
                        {
                            Editor.TheEditor.AddSourceEditor(member, GetBoundLangType(newMemberForm._type));
                        });
                    }
                }).Start();
            }
            newMemberForm.Dispose();
        }
Пример #15
0
        public void TestSerialization()
        {
            var sut = new NewMember();

            JsonHelper.GetSerializedKeys(sut).Should().BeEquivalentTo(new SortedSet <string> {
                "email", "status", "roles"
            });
        }
Пример #16
0
        public async Task <IActionResult> Create([FromBody] NewMember newMember)
        {
            var member   = _mapper.Map <NewMember, Core.CoreModels.Member>(newMember);
            var memberId = await _membersService.Create(member);

            return(Ok(new CreatedMember {
                MemberId = memberId
            }));
        }
Пример #17
0
        public ActionResult AddMember([FromBody] NewMember member)
        {
            var response = _memberService.AddMember(member);

            if (response == null)
            {
                return(BadRequest());
            }

            return(CreatedAtAction(nameof(GetMember), new { CardId = member.CardId }, response));
        }
Пример #18
0
        public async Task <Member> InviteMember(string org, NewMember data)
        {
            var req = new HttpRequestMessage(HttpMethod.Post, $"/{org}/members").WithJsonContent(data);

            req.Headers.Authorization = await tokenProvider.AcquireAuthHeader();

            var response = await api.SendAsync(req);

            await response.EnsureSuccess();

            return(await response.Content.ReadAsAsync <Member>());
        }
Пример #19
0
 public ActionResult Edit([Bind(Include = "policyNo,title,fName,lName,IdNo,dOb,age,gender,maritalStat,telNo,cellNo,CustEmail,fascimileNo,physicalAddress,postalAddress,dateAdded,Policyplan,Premium,Category,addDep,paying")] NewMember newMember)
 {
     if (ModelState.IsValid)
     {
         newMember.Premium         = 252;
         newMember.dateAdded       = DateTime.Now;
         db.Entry(newMember).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(newMember));
 }
Пример #20
0
        public IActionResult Post([FromBody] NewMember memberModel)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            _zsysUserService.CreateNewMember(new ZSysUserDTO {
                DOB = memberModel.DateOfBirth, Email = memberModel.EmailAddress, Notes = memberModel.Notes
            });

            return(Ok());
        }
        private async Task <NewMember> ParseMemberCategory(User[] users)
        {
            var lastMember    = users.Last();
            var newMembers    = new NewMember();
            var allNewMember  = new StringBuilder();
            var allNoUsername = new StringBuilder();
            var allNewBot     = new StringBuilder();

            ConsoleHelper.WriteLine($"Parsing new {users.Length} members..");
            foreach (var newMember in users)
            {
                var isBan = await CheckGlobalBanAsync(newMember);

                if (isBan)
                {
                    continue;
                }

                if (Bot.HostingEnvironment.IsProduction())
                {
                    // var isCasBan = await IsCasBan(newMember.Id);
                    await newMember.IsCasBanAsync();
                }

                var fullName = (newMember.FirstName + " " + newMember.LastName).Trim();
                var nameLink = MemberHelper.GetNameLink(newMember.Id, fullName);

                if (newMember != lastMember)
                {
                    allNewMember.Append(nameLink + ", ");
                }
                else
                {
                    allNewMember.Append(nameLink);
                }

                if (newMember.Username == "")
                {
                    allNoUsername.Append(nameLink);
                }

                if (newMember.IsBot)
                {
                    allNewBot.Append(nameLink);
                }
            }

            newMembers.AllNewMember  = allNewMember;
            newMembers.AllNoUsername = allNoUsername;
            newMembers.AllNewBot     = allNewBot;

            return(newMembers);
        }
Пример #22
0
        public ActionResult New(NewMember data)
        {
            var newMember = new Member {
                Name  = data.Name,
                Email = data.Email
            };

            _context.Members.Add(newMember);
            _context.SaveChanges();

            return(Json(JsonConvert.SerializeObject(newMember)));
        }
Пример #23
0
        private void memberToolStripMenuItem_Click(object sender, EventArgs e)
        {
            RemoteSource member;
            NewMember    newMemberForm = new NewMember();

            newMemberForm.ShowDialog();
            if (newMemberForm.created)
            {
                member = new RemoteSource("", newMemberForm._lib, newMemberForm._spf, newMemberForm._mbr, newMemberForm._type, true);
                OpenSource(member);
            }
            newMemberForm.Dispose();
        }
Пример #24
0
        //[HttpPost]
        //public List<NewMember> search(string policynumber)
        //{
        //    var member = db.NewMembers.ToList().FindAll(s => s.policyNo == policynumber);
        //    var dep = db.Dependants.ToList().FindAll(p => p.policyNo == policynumber);
        //    if (!String.IsNullOrEmpty(policynumber))
        //    {
        //        foreach(NewMember n in member)
        //        {
        //            foreach(Dependant d in dep)
        //            {
        //                List<NewMember> newm=(from m in member
        //                 join de in dep
        //                 on n.policyNo equals d.policyNo
        //                 where n.policyNo == policynumber
        //                 select de).ToList();
        //            }
        //        }
        //    }

        //    return member;
        //}
        public ActionResult Details(string id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            NewMember newMember = db.NewMembers.Find(id);

            if (newMember == null)
            {
                return(HttpNotFound());
            }
            return(View(newMember));
        }
Пример #25
0
        public void NewMember_WhenAddingABlankEmail_ShouldThrowException()
        {
            // Arrange
            var sut       = new MembersController();
            var newMember = new NewMember
            {
                Name = "John Smith"
            };

            // Act

            // Assert
            Assert.Throws <DbEntityValidationException>(() => sut.New(newMember));
        }
Пример #26
0
 public string Delete(NewMember x)
 {
     try {
         string sql = string.Format(@"DELETE Members WHERE Id = {0}", x.id);
         using (SqlConnection connection = new SqlConnection(G.connectionString)) {
             connection.Open();
             using (SqlCommand command = new SqlCommand(sql, connection)) {
                 command.ExecuteNonQuery();
             }
             connection.Close();
         }
         return(JsonConvert.SerializeObject(LoadData(), Formatting.None));
     } catch (Exception e) { return(JsonConvert.SerializeObject(e.Message, Formatting.None)); }
 }
Пример #27
0
        public void NewMember_WhenAddingABlankUserName_ShouldThrowException()
        {
            // Arrange
            var sut       = new MembersController();
            var newMember = new NewMember
            {
                Email = "*****@*****.**"
            };

            // Act

            // Assert
            Assert.Throws <DbEntityValidationException>(() => sut.New(newMember));
        }
Пример #28
0
        /// <summary>
        /// Adds a new member
        /// </summary>
        /// <param name="member"></param>
        /// <param name="createdByUserId">The ID of the user that is creating this member</param>
        /// <param name="churchId">The churchId of the church that this new member belongs</param>
        /// <returns>New ID of the member, or -1 if no id was returned</returns>
        public RepositoryActionResult <NewMember> Add(NewMember member)
        {
            var proc = "CreateMember";

            var paramz = new List <SqlParameter>();

            paramz.Add(new SqlParameter("ChurchId", member.ChurchId));
            paramz.Add(new SqlParameter("createdByUserId", member.CreatedByUserId));
            paramz.Add(new SqlParameter("firstName", member.FirstName.ToSqlString()));
            paramz.Add(new SqlParameter("middleName", member.MiddleName.ToSqlString()));
            paramz.Add(new SqlParameter("lastName", member.LastName.ToSqlString()));
            paramz.Add(new SqlParameter("dateCame", member.DateCame));
            paramz.Add(new SqlParameter("isGroup", member.IsGroup));
            paramz.Add(new SqlParameter("prayed", member.Prayed));
            paramz.Add(new SqlParameter("line1", member.Line1.ToSqlString()));
            paramz.Add(new SqlParameter("city", member.City.ToSqlString()));
            paramz.Add(new SqlParameter("state", member.State.ToSqlString()));
            paramz.Add(new SqlParameter("zip", member.Zip.ToSqlString()));
            paramz.Add(new SqlParameter("phone", member.Phone.ToSqlString()));
            paramz.Add(new SqlParameter("phone2", member.Phone2.ToSqlString()));
            paramz.Add(new SqlParameter("email", member.Email.ToSqlString()));

            var table = new DataTable();

            table.Columns.Add("Id", typeof(int));
            member.SponsorList.ToList().ForEach(s => table.Rows.Add(s.SponsorId));
            paramz.Add(new SqlParameter("sponsorIds", table));

            Func <SqlDataReader, int> readFx = (reader) =>
            {
                return((int)reader["MemberId"]);
            };

            var list = _executor.ExecuteSql <int>(proc, CommandType.StoredProcedure, paramz, readFx);

            var memberId = list.FirstOrDefault();

            if (memberId != 0)
            {
                member.id = memberId;

                return(new RepositoryActionResult <NewMember>(member, RepositoryActionStatus.Created));
            }
            else
            {
                return(new RepositoryActionResult <NewMember>(member, RepositoryActionStatus.NotFound));
            }
        }
Пример #29
0
        public void NewMember_WhenAddingDuplicateEmail_ShouldThrowException()
        {
            // Arrange
            var sut       = new MembersController();
            var newMember = new NewMember
            {
                Name  = "Person 6",
                Email = "*****@*****.**"
            };

            // Act
            sut.New(newMember);

            // Assert
            Assert.Throws <DbUpdateException>(() => sut.New(newMember));
        }
Пример #30
0
        private void addmember_Click(object sender, EventArgs e)
        {
            NewMember newMemberForm = new NewMember(library.Text.Trim(), spf.Text.Trim());

            newMemberForm.ShowDialog();

            if (newMemberForm.created)
            {
                ListViewItem curItem = new ListViewItem(new string[3] {
                    newMemberForm._mbr, newMemberForm._type, newMemberForm._text
                }, 0);
                curItem.Tag = new RemoteSource("", library.Text.Trim(), spf.Text.Trim(), newMemberForm._mbr, newMemberForm._type);
                memberList.Items.Add(curItem);
            }

            newMemberForm.Dispose();
        }