예제 #1
0
 public void CreateUser(ClaimsIdentity userLogin)
 {
     ipphoneEntities.Users.Add(new User {
         Name = userLogin.Name
     });
     ipphoneEntities.SaveChanges();
 }
예제 #2
0
 public void DeleteInDatabase(Guid id)
 {
     using (var ipPhoneEntities = new IPPhoneEntities())
     {
         var contact = ipPhoneEntities.Contacts.SingleOrDefault(c => c.Id.Equals(id));
         if (contact != null)
         {
             ipPhoneEntities.Contacts.Remove(contact);
         }
         ipPhoneEntities.SaveChanges();
     }
 }
예제 #3
0
        public void CreateInDatabase(ChargeLevel chargeLevel)
        {
            if (chargeLevel == null)
            {
                throw new ArgumentNullException(nameof(chargeLevel));
            }

            using (var ipPhoneEntities = new IPPhoneEntities())
            {
                ipPhoneEntities.ChargeLevels.Add(chargeLevel);

                ipPhoneEntities.SaveChanges();
            }
        }
예제 #4
0
        public void UpdateInDatabase(int id, ContactEntity contactEntity)
        {
            if (contactEntity == null)
            {
                throw new ArgumentNullException(nameof(contactEntity));
            }

            var contact = contactEntity.ToModel();

            using (var ipPhoneEntities = new IPPhoneEntities())
            {
                ipPhoneEntities.SaveChanges();
            }
        }
예제 #5
0
        public void DeleteFromDatabase(int level)
        {
            using (var ipPhoneEntities = new IPPhoneEntities())
            {
                var chargeLevel = ipPhoneEntities.ChargeLevels.SingleOrDefault(c => c.Level == level);

                if (chargeLevel != null)
                {
                    ipPhoneEntities.ChargeLevels.Remove(chargeLevel);
                }

                ipPhoneEntities.SaveChanges();
            }
        }
예제 #6
0
        public void CreateInDatabase(ContactEntity contactEntity)
        {
            if (contactEntity == null)
            {
                throw new ArgumentNullException(nameof(contactEntity));
            }

            var contact = contactEntity.ToModel();

            contact.Id = Guid.NewGuid();


            using (var ipPhoneEntities = new IPPhoneEntities())
            {
                ipPhoneEntities.Contacts.Add(contact);
                ipPhoneEntities.SaveChanges();
            }
        }
예제 #7
0
        public void InsertUserToken(User user, string token)
        {
            using (IPPhoneEntities ipphoneEntities = new IPPhoneEntities())
            {
                DateTime today = DateTime.Now.Date;

                List <UserToken> userExpired = ipphoneEntities.UserTokens.Where(t => t.ExpiredTime < today).ToList();

                if (userExpired.Count != 0)
                {
                    ipphoneEntities.UserTokens.RemoveRange(userExpired);
                }

                ipphoneEntities.UserTokens.Add(new UserToken {
                    UserName = user.Name, Token = token, ExpiredTime = today.AddDays(10)
                });

                ipphoneEntities.SaveChanges();
            }
        }
예제 #8
0
        public void UpdateInDatabase(int level, ChargeLevel chargeLevel)
        {
            if (chargeLevel == null)
            {
                throw new ArgumentNullException(nameof(chargeLevel));
            }

            using (var ipPhoneEntities = new IPPhoneEntities())
            {
                var focusChargeLevel = ipPhoneEntities.ChargeLevels.FirstOrDefault(c => c.Level == chargeLevel.Level);

                if (focusChargeLevel != null)
                {
                    focusChargeLevel.Level  = chargeLevel.Level;
                    focusChargeLevel.Charge = chargeLevel.Charge;
                }

                ipPhoneEntities.SaveChanges();
            }
        }