public ActionResult Donations_DestroyById([DataSourceRequest] DataSourceRequest request, SponsorActivityViewModel sponsorActivity, int id) { if (ModelState.IsValid) { try { _Service.DeleteDonationById(id); _Log.LogUsage("delete Donation, Id: " + id); } catch (Exception ex) { ErrorSignal.FromCurrentContext().Raise(ex); } // db.Sponsors.Remove(entity); // db.SaveChanges(); } return(Json(new[] { sponsorActivity }.ToDataSourceResult(request, ModelState))); }
public ActionResult Sponsors_AddSponsorActivity([DataSourceRequest] DataSourceRequest request, SponsorActivityViewModel sponsor, string id) { if (!String.IsNullOrEmpty(id)) { var entity = new SponsorActivity(); entity.SponsorId = Int32.Parse(id); entity.PostedDate = DateTime.Now; entity.Author = User.Identity.Name; _Service.SaveSponsorActivity(entity); _Log.LogUsage("Add new SponsorActivity, Id: " + entity.Id); } return(Json(new[] { sponsor }.ToDataSourceResult(request, ModelState))); }
public ActionResult SponsorActivity_UpdateById([DataSourceRequest] DataSourceRequest request, SponsorActivityViewModel sponsorActivity, int id) { var modelStateErrors = this.ModelState.Keys.SelectMany(key => this.ModelState[key].Errors); if (modelStateErrors.Count() > 0) { foreach (var ert in modelStateErrors) { ModelState.AddModelError("error -", ert.ErrorMessage); } } if (ModelState.IsValid) { try { var entity = _Service.GetSponsorActivitiesById(id); // entity.SponsorId = sponsorActivity.SponsorId; // entity.PostedDate = sponsorActivity.PostedDate; entity.Author = User.Identity.Name; entity.Description = sponsorActivity.Description; entity.ActivityName = sponsorActivity.ActivityName; _Service.SaveSponsorActivity(entity); _Log.LogUsage("Update SponsorActivity, Id: " + entity.Id); } catch (Exception ex) { ErrorSignal.FromCurrentContext().Raise(ex); } //db.Entry(entity).State = EntityState.Modified; //db.SaveChanges(); } return(Json(new[] { sponsorActivity }.ToDataSourceResult(request, ModelState))); }
public ActionResult SponsorActivity_CreateById([DataSourceRequest] DataSourceRequest request, SponsorActivityViewModel orphan, int id) { return(Json(new[] { orphan }.ToDataSourceResult(request, ModelState))); }