public IHttpActionResult PutCustomerProfile(int id, CustomerProfile customerProfile) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != customerProfile.Id) { return(BadRequest()); } db.Entry(customerProfile).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!CustomerProfileExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult PutVehicleProblem(int id, VehicleProblem vehicleProblem) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != vehicleProblem.Id) { return(BadRequest()); } db.Entry(vehicleProblem).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!VehicleProblemExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult PutBooking(int id, Booking booking) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != booking.Id) { return(BadRequest()); } db.Entry(booking).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!BookingExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult PutMechanicOffer(int id, MechanicOffer mechanicOffer) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != mechanicOffer.Id) { return(BadRequest()); } db.Entry(mechanicOffer).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!MechanicOfferExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public ActionResult Create([Bind(Include = "Id,Name")] VehicleType vehicleType) { if (ModelState.IsValid) { db.VehicleTypes.Add(vehicleType); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(vehicleType)); }
public ActionResult Create([Bind(Include = "Name,Description,EstimatedPrice,VehicleTypeId", Exclude = "VehicleType")] VehicleProblem vehicleProblem) { if (ModelState.IsValid) { db.VehicleProblems.Add(vehicleProblem); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.VehicleTypeId = new SelectList(db.VehicleTypes, "Id", "Name", vehicleProblem.VehicleTypeId); return(View(vehicleProblem)); }
public void SaveMyLocationAndTime(Location location, string userId) { User customer = serviserDb.Users.Find(userId); customer.Longitude = location.Longitude; customer.Latitude = location.Latitude; customer.LastOnlineTime = DateTime.Now; serviserDb.SaveChanges(); }
public ActionResult Edit(AccountEditViewModel accountEditViewModel, HttpPostedFileBase profileImage) { ServiserDbContext db = new ServiserDbContext(); User user = User.Identity.GetUser(true); if (user.Id == accountEditViewModel.UserId) { user.FirstName = accountEditViewModel.FirstName; user.LastName = accountEditViewModel.LastName; user.Email = accountEditViewModel.Email; user.PhoneNumber = accountEditViewModel.PhoneNumber; user.UserName = accountEditViewModel.Email; } if (user.MechanicProfile != null && user.MechanicProfile.Id == accountEditViewModel.MechanicProfileId) { user.MechanicProfile.CNIC = accountEditViewModel.CNIC; } if (user.CustomerProfile != null && user.CustomerProfile.Id == accountEditViewModel.CustomerProfileId) { } if (profileImage.ContentLength > 0) { string remoteDirectoryPath = "~/Data_Files/UserProfileImages/"; string remoteFilePath = remoteDirectoryPath + Guid.NewGuid().ToString() + Path.GetFileName(profileImage.FileName); string localPath = Server.MapPath(remoteFilePath); Directory.CreateDirectory(Server.MapPath(remoteDirectoryPath)); profileImage.SaveAs(localPath); if (user.ProfileImageUrl != null && !String.IsNullOrWhiteSpace(user.ProfileImageUrl)) { string localFilePath = Server.MapPath(user.ProfileImageUrl); if (System.IO.File.Exists(localFilePath)) { System.IO.File.Delete(localFilePath); user.ProfileImageUrl = null; } } user.ProfileImageUrl = remoteFilePath; } db.Entry(user).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index", "Home")); }