public bool DeleteCheckIn(int checkInId) { using (Entities entity = new Entities(BaseBISL.ConnectionString)) { WeightCheckIn checkIn = entity.WeightCheckIns.Where(e => e.CheckInID == checkInId).FirstOrDefault(); if (checkIn != null) { entity.DeleteObject(checkIn); int count = entity.SaveChanges(); if (count > 0) return true; } } return false; }
public bool UpdateAccount(AccountModel accountModel) { using (Entities entity = new Entities(BaseBISL.ConnectionString)) { WeightUser user = entity.WeightUsers.Where(e => e.UserID == accountModel.UserId).FirstOrDefault(); if (user != null) { //user.UserName = accountModel.UserName; user.DisplayName = accountModel.DisplayName; user.GoalWeight = accountModel.GoalWeight; user.StartWeight = accountModel.StartWeight; user.EndWeight = accountModel.EndWeight; user.Admin = accountModel.Admin; user.Paid = accountModel.Paid; int count = entity.SaveChanges(); if (count > 0) return true; } } return false; }
public bool RegisterAccount(RegisterModel model) { using (Entities entity = new Entities(BaseBISL.ConnectionString)) { WeightUser user = new WeightUser(); user.UserName = model.UserName; user.PW = model.Password; user.SignUpDateTime = DateTime.Now; entity.AddToWeightUsers(user); int count = entity.SaveChanges(); if (count > 0) return true; } return false; }
public bool InsertPost(PostModel postModel) { using (Entities entity = new Entities(BaseBISL.ConnectionString)) { WeightMsg_Post post = new WeightMsg_Post(); post.DateCreated = DateTime.Now; post.DateModified = DateTime.Now; post.Post_Content = postModel.PostContent; post.Title = postModel.Title; post.UserID = postModel.UserId; entity.AddToWeightMsg_Post(post); int rows = entity.SaveChanges(); if (rows > 0) return true; else return false; } }
public bool InsertComment(CommentModel commentModel) { using (Entities entity = new Entities(BaseBISL.ConnectionString)) { WeightMsg_Comment comment = new WeightMsg_Comment(); comment.Comment_DateTime = DateTime.Now; comment.Comment_HTML = commentModel.CommentContent; comment.Post_ID = commentModel.PostId; comment.UserID = commentModel.UserId; entity.AddToWeightMsg_Comment(comment); int rows = entity.SaveChanges(); if (rows > 0) return true; else return false; } }
public bool InsertWeightCheckIn(WeightCheckInModel model) { using (Entities entity = new Entities(BaseBISL.ConnectionString)) { WeightCheckIn checkIn = new WeightCheckIn(); checkIn.UserID = model.UserId; checkIn.Weight = model.Weight; checkIn.CheckInDate = model.CheckInDate; entity.AddToWeightCheckIns(checkIn); int count = entity.SaveChanges(); if (count > 0) return true; } return false; }
public bool UpdateCheckIn(WeightCheckInModel model) { using (Entities entity = new Entities(BaseBISL.ConnectionString)) { WeightCheckIn checkIn = entity.WeightCheckIns.Where(e => e.CheckInID == model.CheckInId).FirstOrDefault(); if (checkIn != null) { //user.UserName = accountModel.UserName; checkIn.CheckInDate = model.CheckInDate; checkIn.Weight = model.Weight; int count = entity.SaveChanges(); if (count > 0) return true; } } return false; }