public static bl_GuestList_Result UnAssignPlusOnePerk(long userID) { using (var metadata = DataAccess.getDesktopMetadata()) { var qU = (from row in metadata.db_User where row.userID == userID select row.allowPlusOne).FirstOrDefault(); if (qU == false) { var result1 = new bl_GuestList_Result { hasError = true }; return(result1); } var qUser = (from row in metadata.db_User where row.userID == userID select row).FirstOrDefault(); qUser.allowPlusOne = false; metadata.SaveChanges(); var result = new bl_GuestList_Result { hasError = false }; return(result); } }
public static bl_GuestList_Result ResetPassword(long userID, string oldPassword, string newPassword) { using (var metadata = DataAccess.getDesktopMetadata()) { //Get original guest record var qGuest = (from row in metadata.db_User where row.userID == userID select row).FirstOrDefault(); var item = qGuest; if (item == null) { throw new NullReferenceException("No Guest found"); } //validate password if (!PasswordManager.verify(oldPassword, qGuest.PasswordHash)) { return(null); } item.PasswordHash = PasswordManager.encrypt(newPassword); metadata.SaveChanges(); var result = new bl_GuestList_Result { hasError = false }; return(result); } }
public static bl_GuestList_Result UpdateGuest(bl_GuestList info) { using (var metadata = DataAccess.getDesktopMetadata()) { //Get original guest record var qGuest = (from row in metadata.db_User where row.userID == info.userID select row).FirstOrDefault(); var item = qGuest; if (item == null) { throw new NullReferenceException("No Guest found"); } item.hasRSVPd = info.hasRSVPd; item.isAttending = info.isAttending; metadata.SaveChanges(); var result = new bl_GuestList_Result { hasError = false }; return(result); } }
public static bl_GuestList_Result Edit(bl_GuestList info) { using (var metadata = DataAccess.getDesktopMetadata()) { //Get original guest record var qGuest = (from row in metadata.db_User where row.userID == info.userID select row).FirstOrDefault(); //Check if their is a duplicate var qDuplicate = (from row in metadata.db_User where row.Email.ToLower().Trim() == info.Email.ToLower().Trim() && row.userID != info.userID select row).FirstOrDefault(); var item = qGuest; if (item == null) { throw new NullReferenceException("No Guest found"); } var duplicate = qDuplicate; if (duplicate == null) { item.FirstName = info.FirstName; item.LastName = info.LastName; item.Email = info.Email; item.Cell = info.Cell; item.allowPlusOne = info.allowPlusOne; item.groupCoupleID = info.groupCoupleID; metadata.SaveChanges(); var result = new bl_GuestList_Result { hasError = false }; return(result); } else { var result = new bl_GuestList_Result { hasError = true, ErrorText = "Email already exist for another Guest" }; return(result); } } }
public static bl_GuestList_Result Add(bl_GuestList info) { using (var metadata = DataAccess.getDesktopMetadata()) { var qDuplicate = (from row in metadata.db_User where row.Email.ToLower().Trim() == info.Email.ToLower().Trim() select row).FirstOrDefault(); if (qDuplicate == null) { var newGuest = new db_User { FirstName = info.FirstName, LastName = info.LastName, Email = info.Email, Cell = info.Cell, PasswordHash = info.PasswordHash, allowPlusOne = info.allowPlusOne, isPlusOne = info.isPlusOne, groupCoupleID = info.groupCoupleID, isGuest = info.isGuest, isAdmin = info.isAdmin, hasRSVPd = info.hasRSVPd, isAttending = info.isAttending, }; metadata.db_User.Add(newGuest); metadata.SaveChanges(); var result = new bl_GuestList_Result { hasError = false, }; return(result); } else { var result = new bl_GuestList_Result { hasError = true, ErrorText = "Email already exist for another Guest" }; return(result); } } }