public Boolean CheckCode([FromBody] SmartHouseUser user) { SmartHouseUser userFound = DbContext.SmartHouseUser.Where(p => p.SmartHouseUserCode == user.SmartHouseUserCode).Select(p => p).FirstOrDefault(); if (userFound != null) { return(false); } return(true); }
public SmartHouse CloseDoor([FromBody] SmartHouseUser user) { var userFound = DbContext.SmartHouseUser.Where(p => p.SmartHouseUserCode == user.SmartHouseUserCode && p.SmartHouseUserIsDesactivated != true).Select(p => p).FirstOrDefault(); if (userFound != null) { SmartHouse mySwitch = DbContext.SmartHouse.Where(p => p.SmartHouseType == 2).Select(p => p).FirstOrDefault(); mySwitch.SmartHouseIsClosed = true; DbContext.SmartHouseEntry.Add(new SmartHouseEntry() { SmartHouseEntryDate = DateTime.Now, SmartHouseUserId = userFound.SmartHouseUserId, SmartHouseEntryType = "Close" }); DbContext.SaveChanges(); } return(GetDoorSwitch()); }
public List <SmartHouseUser> UpdateUser([FromBody] SmartHouseUser user) { SmartHouseUser myUser = DbContext.SmartHouseUser.Where(p => p.SmartHouseUserId == user.SmartHouseUserId).Select(p => p).FirstOrDefault(); myUser.SmartHouseUserArrival = user.SmartHouseUserArrival; myUser.SmartHouseUserCode = user.SmartHouseUserCode; myUser.SmartHouseUserEmail = user.SmartHouseUserEmail; myUser.SmartHouseUserLeave = user.SmartHouseUserLeave; myUser.SmartHouseUserName = user.SmartHouseUserName; myUser.SmartHouseUserPhone = user.SmartHouseUserPhone; myUser.SmartHouseUserAmount = user.SmartHouseUserAmount; myUser.SmartHouseUserIsDesactivated = user.SmartHouseUserIsDesactivated; // DbContext.Update(user); try this DbContext.SaveChanges(); return(GetUserList()); }
public List <SmartHouseUser> SaveUser([FromBody] SmartHouseUser user) { DbContext.Add(user); DbContext.SaveChanges(); return(GetUserList()); }