public void CreateUser(ClaimsIdentity userLogin) { ipphoneEntities.Users.Add(new User { Name = userLogin.Name }); ipphoneEntities.SaveChanges(); }
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(); } }
public void CreateInDatabase(ChargeLevel chargeLevel) { if (chargeLevel == null) { throw new ArgumentNullException(nameof(chargeLevel)); } using (var ipPhoneEntities = new IPPhoneEntities()) { ipPhoneEntities.ChargeLevels.Add(chargeLevel); ipPhoneEntities.SaveChanges(); } }
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(); } }
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(); } }
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(); } }
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(); } }
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(); } }