public ActionResult DeleteConfirmed(Guid id) { HotelFeature hotelFeature = db.HotelFeatures.Find(id); hotelFeature.IsDelete = true; hotelFeature.DeleteDate = DateTime.Now; db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit(HotelFeature hotelFeature) { if (ModelState.IsValid) { hotelFeature.IsDelete = false; db.Entry(hotelFeature).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.FeatureId = new SelectList(db.Features, "Id", "Icon", hotelFeature.FeatureId); ViewBag.HotelId = hotelFeature.HotelId; return(View(hotelFeature)); }
public ActionResult Delete(Guid?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } HotelFeature hotelFeature = db.HotelFeatures.Find(id); if (hotelFeature == null) { return(HttpNotFound()); } return(View(hotelFeature)); }
public ActionResult Edit(Guid?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } HotelFeature hotelFeature = db.HotelFeatures.Find(id); if (hotelFeature == null) { return(HttpNotFound()); } ViewBag.FeatureId = new SelectList(db.Features, "Id", "Icon", hotelFeature.FeatureId); ViewBag.HotelId = hotelFeature.HotelId; return(View(hotelFeature)); }
public ActionResult Create(HotelFeature hotelFeature, Guid id) { if (ModelState.IsValid) { hotelFeature.HotelId = id; hotelFeature.IsDelete = false; hotelFeature.SubmitDate = DateTime.Now; hotelFeature.Id = Guid.NewGuid(); db.HotelFeatures.Add(hotelFeature); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.FeatureId = new SelectList(db.Features, "Id", "Icon", hotelFeature.FeatureId); ViewBag.HotelId = id; return(View(hotelFeature)); }
public HotelDto EditHotel(HotelDto hotelDto, int userId, int tenantId, List <MemoryStream> files, string path, int imageCounter) { var hotelObj = _hotelService.Query(x => x.HotelId == hotelDto.HotelId && x.TenantId == tenantId).Select().FirstOrDefault(); if (hotelObj == null) { throw new NotFoundException(ErrorCodes.ProductNotFound); } // ValidateHotel(hotelDto, tenantId); foreach (var hotelName in hotelDto.TitleDictionary) { var hotelTranslation = hotelObj.HotelTranslations.FirstOrDefault(x => x.Language.ToLower() == hotelName.Key.ToLower() && x.HotelId == hotelDto.HotelId); if (hotelTranslation == null) { hotelObj.HotelTranslations.Add(new HotelTranslation { Title = hotelName.Value, Description = hotelDto.DescriptionDictionary[hotelName.Key], Language = hotelName.Key }); } else { hotelTranslation.Title = hotelName.Value; hotelTranslation.Description = hotelDto.DescriptionDictionary[hotelName.Key]; } } hotelObj.CityId = hotelDto.CityId; hotelObj.Latitude = hotelDto.Latitude; hotelObj.Longitude = hotelDto.Longitude; hotelObj.Star = hotelDto.Star; hotelObj.LastModificationTime = Strings.CurrentDateTime; hotelObj.LastModifierUserId = userId; hotelObj.IsDeleted = hotelDto.IsDeleted; hotelObj.CurrencyId = hotelDto.CurrencyId; var deleteFatures = new HotelFeature[hotelObj.HotelFeature.Count]; hotelObj.HotelFeature.CopyTo(deleteFatures, 0); foreach (var objRolePermission in deleteFatures) { _hotelFeatureService.Delete(objRolePermission); } foreach (var roleper in hotelDto.HotelFeature) { if (hotelObj.HotelFeature.All(x => x.FeatureId != roleper.FeatureId)) { hotelObj.HotelFeature.Add(new HotelFeature { FeatureId = roleper.FeatureId }); } } _hotelFeatureService.InsertRange(hotelObj.HotelFeature); _hotelService.Update(hotelObj); SaveChanges(); var imageId = 1; //imageCounter + 1; foreach (var memoryStream in files) { _manageStorage.UploadImage(path + "\\" + "Hotel-" + hotelObj.HotelId, memoryStream, imageId.ToString()); imageId++; } return(hotelDto); }