コード例 #1
0
        public void rateAddress(int rate, long id)
        {
            using (var context = new RoomRentEntities())
            {
                var address = context.UserAddresses
                              .Where(c => c.addr_id == id)
                              .FirstOrDefault();
                if (address != null)
                {
                    if (address.rateCount != null)
                    {
                        double?temp = (address.rateCount * address.rate + rate) / (address.rateCount + 1);
                        address.rateCount += 1;
                        address.rate       = temp;
                    }
                    else
                    {
                        address.rateCount = 1;
                        address.rate      = rate;
                    }

                    context.SaveChanges();
                }
            }
        }
コード例 #2
0
 public void addRent(Rents address)
 {
     using (var context = new RoomRentEntities())
     {
         context.Rents.Add(address);
         context.SaveChanges();
     }
 }
コード例 #3
0
 public void addUserAddress(UserAddresses userAddresses)
 {
     using (var context = new RoomRentEntities())
     {
         context.UserAddresses.Add(userAddresses);
         context.SaveChanges();
     }
 }
コード例 #4
0
        public long addAddress(Addresses address)
        {
            Addresses temp = new Addresses();

            using (var context = new RoomRentEntities())
            {
                temp = context.Addresses.Add(address);
                context.SaveChanges();
            }

            return(temp.id);
        }
コード例 #5
0
 public void isRated(long id, int value)
 {
     using (var context = new RoomRentEntities())
     {
         var personal = context.Rents
                        .Where(c => c.id == id)
                        .FirstOrDefault();
         if (personal != null)
         {
             personal.isRated = true;
             personal.rate    = value;
             context.SaveChanges();
         }
     }
 }
コード例 #6
0
        public void deleteRent(long v)
        {
            using (var context = new RoomRentEntities())
            {
                var temp = context.Rents
                           .Where(c => c.id == v)
                           .FirstOrDefault();

                if (temp != null)
                {
                    context.Rents.Remove(temp);
                    context.SaveChanges();
                }
            }
        }
コード例 #7
0
 public void updateUser(Users user)
 {
     using (var context = new RoomRentEntities())
     {
         var temp = context.Users
                    .Where(c => c.username == user.username)
                    .FirstOrDefault();
         if (temp != null)
         {
             temp.email_addr = user.email_addr;
             temp.acc_type   = user.acc_type;
             context.SaveChanges();
         }
     }
 }
コード例 #8
0
 public void updatePersonalData(PersonalData personalData)
 {
     using (var context = new RoomRentEntities())
     {
         var temp = context.PersonalData
                    .Where(c => c.id == personalData.id)
                    .FirstOrDefault();
         if (temp != null)
         {
             temp.phone_number = personalData.phone_number;
             temp.name         = personalData.name;
             temp.surname      = personalData.surname;
             context.SaveChanges();
         }
     }
 }
コード例 #9
0
        public long createPersonalData(PersonalData data)
        {
            using (var context = new RoomRentEntities())
            {
                PersonalData personalData = new PersonalData
                {
                    name         = data.name,
                    surname      = data.surname,
                    phone_number = data.phone_number,
                };
                PersonalData returned = context.PersonalData.Add(personalData);
                context.SaveChanges();
            };

            return(getNewDataId(data.phone_number));
        }
コード例 #10
0
 public void createUser(Users user)
 {
     using (var context = new RoomRentEntities())
     {
         Users newUser = new Users
         {
             personal_id = user.personal_id,
             username    = user.username,
             password    = user.password,
             email_addr  = user.email_addr,
             acc_type    = user.acc_type,
             is_active   = true,
             is_banned   = false,
             verified    = true,
             create_date = DateTime.Now,
             salt        = user.salt
         };
         context.Users.Add(newUser);
         context.SaveChanges();
     };
 }