public void DeleteData(int id) { TouristPlaceEntityModel touristPlace = db.TouristPlacesEntityModel.Find(id); db.TouristPlacesEntityModel.Remove(touristPlace); db.SaveChanges(); }
public void EditData(TouristPlaceViewModel touristPlace, HttpPostedFileBase ImageUpload) { if (ImageUpload != null) { string path = HostingEnvironment.MapPath("~/ImageFiles/" + ImageUpload.FileName); ImageUpload.SaveAs(path); touristPlace.Image = "~/ImageFiles/" + ImageUpload.FileName; } TouristPlaceEntityModel touristPlaceEntityModel = ConvertViewToEntityModel(touristPlace); db.Entry(touristPlaceEntityModel).State = EntityState.Modified; db.SaveChanges(); }
private TouristPlaceEntityModel ConvertViewToEntityModel(TouristPlaceViewModel touristPlaceViewModel) { TouristPlaceEntityModel touristPlaceEntityModel = new TouristPlaceEntityModel() { ID = touristPlaceViewModel.ID, Name = touristPlaceViewModel.Name, Address = touristPlaceViewModel.Address, Rating = touristPlaceViewModel.Rating, Type = touristPlaceViewModel.Type, Image = touristPlaceViewModel.Image }; return(touristPlaceEntityModel); }
public bool CheckIfNameExist(string Name, string CurrentName) { if (Name == CurrentName) { return(false); } TouristPlaceEntityModel touristPlaceEntity = db.TouristPlacesEntityModel.AsNoTracking().FirstOrDefault(tp => tp.Name.Equals(Name)); if (touristPlaceEntity == null) { return(false); } return(true); }