public bool create(ProviderModel newProvider) { try { provider provider = new provider(); provider.name = newProvider.name; provider.email = newProvider.email; provider.phone_number = newProvider.phone_number; provider.address = newProvider.address; provider.description = newProvider.description; provider.start_time = DateTime.Now; provider.status = true; db.providers.Add(provider); db.SaveChanges(); return(true); } catch (Exception e) { return(false); } }
public bool updateProviderById(int id, ProviderModel updateProvider) { try { var currentProvider = this.getProviderById(id); if (currentProvider != null) { currentProvider.name = updateProvider.name; currentProvider.email = updateProvider.email; currentProvider.phone_number = updateProvider.phone_number; currentProvider.address = updateProvider.address; currentProvider.description = updateProvider.description; currentProvider.start_time = DateTime.Now; db.Entry(currentProvider).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); return(true); } return(false); } catch (Exception e) { return(false); } }