public string Create(vendor_has_event Model) { DatabaseContext db = new DatabaseContext(); string msg; try { if (ModelState.IsValid) { Model.vendor_idVendor = new Random().Next(1, 1000); db.vendor_has_event.Add(Model); db.SaveChanges(); msg = "Saved Successfully"; } else { msg = "Validation data not successfully"; } } catch (Exception ex) { msg = "Error occured:" + ex.Message; } return(msg); }
public string Delete(string Id) { DatabaseContext db = new DatabaseContext(); vendor_has_event vendor_has_events = db.vendor_has_event.Find(int.Parse(Id)); db.vendor_has_event.Remove(vendor_has_events); db.SaveChanges(); return("Deleted successfully"); }
public string Edit(vendor_has_event Model) { DatabaseContext db = new DatabaseContext(); string msg; try { if (ModelState.IsValid) { db.Entry(Model).State = EntityState.Modified; db.SaveChanges(); msg = "Saved Successfully"; } else { msg = "Validation data not successfully"; } } catch (Exception ex) { msg = "Error occured:" + ex.Message; } return(msg); }