public static void Delete() { try { Console.WriteLine("Please select order status to delete:"); GetList(); Console.Write("Enter ID of order status you want to delete:"); using (SalonContext salonContext = new SalonContext()) { StateRepository stateRepository = new StateRepository(salonContext); List <int> listOfIDs = stateRepository.GetIds(); string idToDelete = Console.ReadLine(); int idOfState; while (!Int32.TryParse(idToDelete, out idOfState) || !listOfIDs.Contains(idOfState)) { Console.WriteLine($"Order status with ID {idOfState} dosent found. Try again: "); idToDelete = Console.ReadLine(); } ISalonManager <State> stateManager = new StateRepository(salonContext); stateManager.Delete(idOfState); Console.WriteLine($"Order status with ID {idToDelete} deleted."); } } catch (Exception ex) { Console.WriteLine("Something went wrong... Try latter"); Console.WriteLine(ex.Message); } }
public static void Delete() { try { Console.WriteLine("Please select order status to delete:"); GetList(); Console.Write("Enter ID of order status you want to delete:"); using (SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString)) { ISalonManager <State> stateManager = new StateRepository(connection); StateRepository checkIds = new StateRepository(connection); List <int> listOfIDs = checkIds.GetIds(); string idToDelete = Console.ReadLine(); int idOfState; while (!Int32.TryParse(idToDelete, out idOfState) || !listOfIDs.Contains(idOfState)) { Console.WriteLine($"Order status with ID {idOfState} dosent found. Try again: "); idToDelete = Console.ReadLine(); } stateManager.Delete(idOfState); Console.WriteLine($"Order status with ID {idToDelete} deleted."); } } catch (Exception ex) { Console.WriteLine("Something went wrong... Try latter"); Console.WriteLine(ex.Message); } }
public ActionResult DeleteState(StateVM stateVM) { var state = new State(); state.StateAbbreviation = stateVM.StateAbbreviation; state.StateName = stateVM.StateName; StateRepository.Delete(state.StateAbbreviation); return(RedirectToAction("States")); }
public ActionResult Delete(int id) { int StateId = id; // countryRepository.Delete(ConId); var e = stateRepository.GetById(id); // TODO: Add delete logic here stateRepository.Delete(e); return(RedirectToAction("Index")); }
public async Task <bool> Delete(Guid id) { State state = await StateRepository.GetById(id); if (state == null) { return(false); } return(await StateRepository.Delete(state)); }
public void Remove <T>(string key) where T : class { lock (stateLocker) { var state = repo.GetState(String.Format("{0}", key)); if (state != null) { repo.Delete(state); } } }
public int DeleteState(int Id) { try { _IStateRepository.Delete(Id); return(_IStateRepository.Save()); } catch (Exception exception) { exception.Log(); return(0); } }
public ActionResult DeleteState(State state) { StateRepository.Delete(state.StateAbbreviation); return(RedirectToAction("States")); }
public ActionResult DeleteState(DeleteStateVM viewModel) { StateRepository.Delete(viewModel.currentState.StateAbbreviation); return(RedirectToAction("States")); }
public ActionResult DeleteStatePost(string StateAbbreviation) { StateRepository.Delete(StateAbbreviation); return(RedirectToAction("States", "Admin")); }
public string Delete(State state) { bool success = StateRepository.Delete(state); return("State removed with success"); }
public void DeleteTest() { int rows = 0; using (DBContext db = new DBContext(settings.Database.ConnectionString, logger)) { Assert.NotNull(db); ContactRepository contactRepos = new ContactRepository(settings, logger, db); CityRepository cityRepos = new CityRepository(settings, logger, db); StateRepository stateRepos = new StateRepository(settings, logger, db); #region Delete Contact Test Contact contact = contactRepos.FindByPK(new PrimaryKey() { Key = 8 }); Assert.NotNull(contact); rows = contactRepos.Delete(new PrimaryKey() { Key = 8 }); Assert.Equal(1, rows); contact = contactRepos.FindByPK(new PrimaryKey() { Key = 8 }); Assert.Null(contact); #endregion #region Delete City Test City city = cityRepos.FindByPK(new PrimaryKey() { Key = 17 }); Assert.NotNull(city); rows = cityRepos.Delete(new PrimaryKey() { Key = 17 }); Assert.Equal(1, rows); city = cityRepos.FindByPK(new PrimaryKey() { Key = 17 }); Assert.Null(city); #endregion #region Delete State Test State state = stateRepos.FindByPK(new PrimaryKey() { Key = "WA" }); Assert.NotNull(state); rows = stateRepos.Delete(new PrimaryKey() { Key = "WA" }); Assert.Equal(1, rows); state = stateRepos.FindByPK(new PrimaryKey() { Key = "WA" }); Assert.Null(state); #endregion } }
public IHttpActionResult Delete(int id) { repo.Delete(id); return(Ok()); }
public async Task DeleteTest() { int rows = 0; using (DBContext db = new DBContext(settings.Database.ConnectionString, logger)) { Assert.NotNull(db); ContactRepository contactRepos = new ContactRepository(settings, logger, db); CityRepository cityRepos = new CityRepository(settings, logger, db); StateRepository stateRepos = new StateRepository(settings, logger, db); ProjectContactRepository projectContactRepos = new ProjectContactRepository(settings, logger, db); #region Delete Contact Test Contact contact = await contactRepos.FindByPK(new PrimaryKey() { Key = 8 }); Assert.NotNull(contact); rows = await contactRepos.Delete(new PrimaryKey() { Key = 8 }); Assert.Equal(1, rows); contact = await contactRepos.FindByPK(new PrimaryKey() { Key = 8 }); Assert.Null(contact); #endregion #region Delete City Test City city = await cityRepos.FindByPK(new PrimaryKey() { Key = 17 }); Assert.NotNull(city); rows = await cityRepos.Delete(new PrimaryKey() { Key = 17 }); Assert.Equal(1, rows); city = await cityRepos.FindByPK(new PrimaryKey() { Key = 17 }); Assert.Null(city); #endregion #region Delete State Test State state = await stateRepos.FindByPK(new PrimaryKey() { Key = "WA" }); Assert.NotNull(state); rows = await stateRepos.Delete(new PrimaryKey() { Key = "WA" }); Assert.Equal(1, rows); state = await stateRepos.FindByPK(new PrimaryKey() { Key = "WA" }); Assert.Null(state); #endregion #region Delete ProjectContact Test ProjectContact projectContact = await projectContactRepos.FindByPK(new PrimaryKey() { CompositeKey = new object[] { 1, 1 }, IsComposite = true }); Assert.NotNull(projectContact); rows = await projectContactRepos.Delete(new PrimaryKey() { CompositeKey = new object[] { 1, 1 }, IsComposite = true }); Assert.Equal(1, rows); projectContact = await projectContactRepos.FindByPK(new PrimaryKey() { CompositeKey = new object[] { 1, 1 }, IsComposite = true }); Assert.Null(projectContact); #endregion } }
public ActionResult DeleteStatePost(string id) { StateRepository.Delete(id); return(RedirectToAction("States")); }