コード例 #1
0
        public int MemberRegister(MemberEnumGender gender, string ssn, string password, string name, string surname, string phone, string mail, DateTime birthday)
        {
            int returnValueInt = 0;

            if (!string.IsNullOrEmpty(ssn) && !string.IsNullOrWhiteSpace(ssn) && !string.IsNullOrEmpty(password) && !string.IsNullOrWhiteSpace(password) && !string.IsNullOrEmpty(name) && !string.IsNullOrWhiteSpace(name) && !string.IsNullOrEmpty(surname) && !string.IsNullOrWhiteSpace(surname) && ssn.Length == 11 && birthday != null)
            {
                string tempPhone;
                string tempMail;
                if (string.IsNullOrEmpty(phone.Trim()))
                {
                    tempPhone = null;
                }
                else
                {
                    tempPhone = phone;
                }
                if (string.IsNullOrEmpty(mail.Trim()))
                {
                    tempMail = null;
                }
                else
                {
                    tempMail = mail;
                }
                using (RepositoryMember repositoryMember = new RepositoryMember())
                {
                    if (!repositoryMember.AnyWithExplicitLoad(I => I.Ssn == ssn))
                    {
                        if (!repositoryMember.AnyWithExplicitLoad(I => I.Phone == phone))
                        {
                            if (!repositoryMember.AnyWithExplicitLoad(I => I.Mail == mail))
                            {
                                repositoryMember.CUDOperation(new Member()
                                {
                                    Id       = Guid.NewGuid(),
                                    Ssn      = ssn,
                                    Name     = BLLHelper.TrimName(name),
                                    Surname  = BLLHelper.TrimSurname(surname),
                                    Gender   = gender,
                                    Birthday = birthday,
                                    Phone    = tempPhone,
                                    Mail     = tempMail,
                                    Password = PasswordCrypto.EncryptToSha512(password),
                                    Picture  = BLLHelper.DefaultUserPic()
                                }, EntityState.Added);
                                returnValueInt = repositoryMember.SaveChanges();
                            }
                            else
                            {
                                returnValueInt = -102;
                            }
                        }
                        else
                        {
                            returnValueInt = -101;
                        }
                    }
                    else
                    {
                        returnValueInt = -100;
                    }
                }
            }
            else
            {
                returnValueInt = -1;
            }
            return(returnValueInt);
        }
コード例 #2
0
 public int MemberInfoUpdate(Member member, string name, string surname, MemberEnumGender memberGender, DateTime birthday, decimal height, decimal weight, bool?smoke, string phone, string mail, string city, string county)
 {
     if (!string.IsNullOrEmpty(name) && !string.IsNullOrWhiteSpace(name) && !string.IsNullOrEmpty(surname) && !string.IsNullOrWhiteSpace(surname) && member != null)
     {
         int?   tempHeight;
         double?tempWeight;
         string tempPhone;
         string tempMail;
         string tempCity;
         string tempCounty;
         if (height == 0)
         {
             tempHeight = null;
         }
         else
         {
             tempHeight = (int)height;
         }
         if (weight == 0)
         {
             tempWeight = null;
         }
         else
         {
             tempWeight = (double)weight;
         }
         if (string.IsNullOrEmpty(phone.Trim()))
         {
             tempPhone = null;
         }
         else
         {
             tempPhone = phone;
         }
         if (string.IsNullOrEmpty(mail.Trim()))
         {
             tempMail = null;
         }
         else
         {
             tempMail = mail;
         }
         if (string.IsNullOrEmpty(city.Trim()))
         {
             tempCity = null;
         }
         else
         {
             tempCity = city;
         }
         if (string.IsNullOrEmpty(county.Trim()))
         {
             tempCounty = null;
         }
         else
         {
             tempCounty = county;
         }
         using (RepositoryMember repositoryMember = new RepositoryMember())
         {
             if (!repositoryMember.AnyWithExplicitLoad(I => I.Id != member.Id && I.Phone == phone))
             {
                 if (!repositoryMember.AnyWithExplicitLoad(I => I.Id != member.Id && I.Mail == mail))
                 {
                     member.Name       = name;
                     member.Surname    = surname;
                     member.Gender     = memberGender;
                     member.Birthday   = birthday;
                     member.Height     = tempHeight;
                     member.Weight     = tempWeight;
                     member.DoesSmoke  = smoke;
                     member.Phone      = tempPhone;
                     member.Mail       = tempMail;
                     member.City       = tempCity;
                     member.County     = tempCounty;
                     member.UpdateTime = DateTime.Now;
                     repositoryMember.CUDOperation(member, EntityState.Modified);
                     return(repositoryMember.SaveChanges());
                 }
                 else
                 {
                     return(-102);
                 }
             }
             else
             {
                 return(-101);
             }
         }
     }
     else
     {
         return(-1);
     }
 }