Example #1
0
 internal object AddBookingRequest(BookingRequestModel requestModel)
 {
     try
     {
         Booking new_request = new Booking
         {
             BookingById        = requestModel.BookingById,
             BookingToId        = requestModel.BookingToId,
             ServiceType        = requestModel.ServiceType,
             BookingDate        = DateTime.Now,
             ServiceDate        = Convert.ToDateTime(requestModel.ServiceDate),
             CustomerAddress    = requestModel.CustomerAddress,
             ProblemDescription = requestModel.ProblemDescription,
             VendorAcceptance   = false,
             CompletedStatus    = false,
         };
         _dbContext.Bookings.Add(new_request);
         _dbContext.SaveChanges();
         return("{Success: true}");
     }
     catch (Exception ex)
     {
         return("{ Success:  " + ex.Message + "}");
     }
 }
Example #2
0
        internal object DeleteProfession(int id)
        {
            UserProfession userProfession = _roofCareDbContext.UserProfessions.Find(id);

            if (userProfession != null)
            {
                _roofCareDbContext.UserProfessions.Remove(userProfession);
                _roofCareDbContext.SaveChanges();
                return("Success");
            }
            else
            {
                return("Already Deleted");
            }
        }
 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 AddUserReview(AddFeedbackModel reviewModel)
        {
            try
            {
                using (_roofCareDbContext)
                {
                    Feedback feedback = new Feedback
                    {
                        FeedbackById = reviewModel.FeedbackById,
                        FeedbackToId = reviewModel.FeedbackToId,
                        Rating       = reviewModel.Rating,
                        FeedbackText = reviewModel.FeedbackText,
                        FeedbackDate = DateTime.Now
                    };

                    _roofCareDbContext.Feedbacks.Add(feedback);
                    _roofCareDbContext.SaveChanges();
                    return("{ Success: true}");
                }
            }
            catch
            {
                return("Success:false");
            }
        }
        internal object Register(AdminRegister registerRequest)
        {
            var old_admin = _dbContext.Admins.Where(a => a.Username == registerRequest.Username).FirstOrDefault();

            if (old_admin == null)
            {
                Admin new_admin = new()
                {
                    FullName = registerRequest.FullName,
                    Username = registerRequest.Username,
                    Password = registerRequest.Password
                };
                _dbContext.Admins.Add(new_admin);
                _dbContext.SaveChanges();
                return(new_admin);
            }
            else
            {
                return("User with username already exists!");
            }
        }
 internal object DeleteUserSaved(int savedId)
 {
     try
     {
         SavedOffer old_saved = _dbContext.SavedOffers.Find(savedId);
         if (old_saved != null)
         {
             _dbContext.Remove(old_saved);
             _dbContext.SaveChanges();
             return("Unsaved");
         }
         else
         {
             return("Offer Save not found");
         }
     }
     catch (Exception ex)
     {
         return(ex.Message);
     }
 }
        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 + "}");
            }
        }
Example #8
0
        internal object RegisterNewUser(RegisterModel user)
        {
            try
            {
                User existing_user = _dbContext.Users.FirstOrDefault(u => u.Username == user.Username);
                if (existing_user == null)
                {
                    User new_user = new User()
                    {
                        Username = user.Username,
                        Password = user.Password,
                        FullName = user.FullName,
                        Gender   = user.Gender,
                        DOB      = user.DOB,
                        UserType = user.UserType,
                        About    = user.About,
                        Contact  = user.Contact,
                        Address  = user.Address,
                        Verified = false
                    };
                    _dbContext.Users.Add(new_user);
                    _dbContext.SaveChanges();

                    var services = _dbContext.Professions.ToList();
                    return(HelperResponse.HelperRegister(true, new_user.UserId, services));
                }
                else
                {
                    return(HelperResponse.HelperRegister(false, -1, null));
                }
            }
            catch (Exception ex)
            {
                return("{Success:" + ex.Message + "}");
            }
        }
Example #9
0
 internal object AddOffer(AddOfferModel offerModel)
 {
     try
     {
         Offer new_offer = new Offer
         {
             UserId           = offerModel.UserId,
             OfferDescription = offerModel.OfferDescription,
             OfferImage       = ParseImage(offerModel.OfferImage),
             ValidDate        = offerModel.ValidDate,
             PostedDate       = DateTime.Now
         };
         _dbContext.Offers.Add(new_offer);
         _dbContext.SaveChanges();
         return("{Success: true}");
     }
     catch (Exception ex)
     {
         return("{Success: " + ex.Message + "}");
     }
 }
 internal object DeleteOffer(int offerId)
 {
     try
     {
         using (_roofCareDbContext)
         {
             Offer oldOffer = _roofCareDbContext.Offers.Find(offerId);
             if (oldOffer != null)
             {
                 _roofCareDbContext.Remove(oldOffer);
                 _roofCareDbContext.SaveChanges();
                 return("Delete Successful");
             }
             else
             {
                 return("Offer doesn't exists!");
             }
         }
     }
     catch (Exception ex)
     {
         return(ex.Message);
     }
 }