Пример #1
0
        public async Task <JsonResult> PostMemberShip(MemberShip memberShip)
        {
            if (memberShip == null)
            {
                throw new ArgumentNullException(" memberShip is Empty");
            }
            string result = "";

            try
            {
                if (memberShip.Name == null || memberShip.Name == "")
                {
                    throw new ArgumentNullException("Name is empty");
                }
                else if (memberShip.Email == null || memberShip.Email == "")
                {
                    throw new ArgumentNullException("Email is empty");
                }

                else
                {
                    if (await memberShipRepository.IsMembershipExists(memberShip.Email))
                    {
                        var id = await memberShipRepository.ActivateMemberShip(memberShip);

                        if (id > 0)
                        {
                            result = "DataSved Successfully";
                        }
                        // return new JsonResult("DataSved Successfully");
                        else
                        {
                            //    return new JsonResult("Failed");
                            result = "Failed";
                        }
                    }
                    else
                    {
                        result = "already Existed";
                    }
                }
            }
            catch (Exception ex)
            {
            }
            return(new JsonResult(result));
        }
Пример #2
0
        public async Task ActivateMemberShipTest()
        {
            try
            {
                MemberShip memberShip = new MemberShip {
                    Name = "Test", Email = "*****@*****.**", ActiveDate = DateTime.Now, DeactiveDate = DateTime.Now.AddMonths(1), IsActive = true
                };
                var result = await memberShipRepository.ActivateMemberShip(memberShip);

                Assert.True(Convert.ToInt32(result) > 0, "The DataSved Successfully !!");
            }
            catch (Exception ex)
            {
                Assert.NotNull(ex);
                Assert.IsType <InvalidOperationException>(ex);
            }
        }