internal object AddProfileImage(ProfileImageModel model) { try { User user = _dbContext.Users.Find(model.UserId); if (user != null) { user.UserImage = ParseImage(model.userImage); _dbContext.Entry(user).State = EntityState.Modified; _dbContext.SaveChanges(); ImageUploadResponse imageResponse = new ImageUploadResponse { Success = true, ImageUrl = user.UserImage }; return(imageResponse); } else { ImageUploadResponse imageResponse = new ImageUploadResponse { Success = false, ImageUrl = null }; return(imageResponse); } } catch (Exception ex) { return("{success:" + ex.Message + "}"); } }
internal object UpdateProfile(UpdateProfileModel model) { try { User old_user = _dbContext.Users.Find(model.UserId); if (old_user != null) { old_user.FullName = model.Name; old_user.Gender = model.Gender; old_user.Address = model.Address; old_user.Contact = model.Contact; old_user.DOB = model.Dob; old_user.About = model.About; _dbContext.Entry(old_user).State = EntityState.Modified; _dbContext.SaveChanges(); return(new Response { Success = true, Message = "Details Updated" }); } else { return(new Response { Success = false, Message = "Update Failed" }); } } catch (Exception ex) { return(new Response { Success = false, Message = "Update Failed" }); } }
internal object AcceptBookingRequest(BillModel billModel) { try { Booking acc_booking = _dbContext.Bookings.Find(billModel.BookingId); if (acc_booking != null) { acc_booking.ServiceCharge = billModel.ServiceCharge; acc_booking.TravellingCost = billModel.TravellingCost; acc_booking.DiscountPercentage = billModel.DiscountPercentage; acc_booking.TotalCharge = billModel.TotalCharge; acc_booking.IssuedDate = DateTime.Now; acc_booking.VendorAcceptance = true; _dbContext.Entry(acc_booking).State = EntityState.Modified; _dbContext.SaveChanges(); return("{Success: true}"); } else { return("{Success: false}"); } } catch (Exception ex) { return("{ Success: " + ex.Message + "}"); } }
internal object UpdateProfession(int id, string professionName) { var old_profession = _dbContext.Professions.Where(p => p.ProfessionId == id).FirstOrDefault(); old_profession.ProfessionName = professionName; _dbContext.Entry(old_profession).State = EntityState.Modified; _dbContext.SaveChanges(); return(true); }
internal object ChangePassword(int userId, string oldPassword, string newPassword) { User user = _roofCareDbContext.Users.Find(userId); if (user != null) { if (user.Password.Equals(oldPassword)) { user.Password = newPassword; _roofCareDbContext.Entry(user).State = EntityState.Modified; _roofCareDbContext.SaveChanges(); return("success"); } else { return("failed"); } } else { return("Invalid user token provided!"); } }
internal object UpdateCompletedStatus(int bookingId) { try { Booking acc_booking = _dbContext.Bookings.Find(bookingId); if (acc_booking != null) { acc_booking.CompletedStatus = true; _dbContext.Entry(acc_booking).State = EntityState.Modified; _dbContext.SaveChanges(); return("true"); } else { return("false"); } } catch (Exception ex) { return("{ Success: " + ex.Message + "}"); } }