Пример #1
0
        public async Task IsMembershipExistsTest()
        {
            var result = await memberShipRepository.IsMembershipExists("*****@*****.**");

            Assert.True(
                result == true,
                "member is exist.");

            Assert.False(
                result == false,
                "member should not exist.");
        }
Пример #2
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));
        }