public virtual ActionResult Save(EditActivityModel model) { if (ModelState.IsValid) { try { e = GetEvent(model.EventId); if (model.Id == Guid.Empty) { a = e.AddActivity(model.Title, model.TimeStamp.FullDate); } else { a = e.IndependentActivities.Where(x => x.Id == model.Id).First(); a.Title = model.Title; a.TimeStamp = model.TimeStamp.FullDate; a.ConvertAllToUTC(); } db.SaveChanges(); } catch (Exception ex) { this.logger.Error(this.GetType(), ex, "Failed saving activity"); ModelState.AddModelError(string.Empty, ex.Message); } } return(ModelState.IsValid ? Json(new { success = true }) : Json(new { success = false, formWithErrorMessages = this.RenderPartialViewToString(MVC.Activity.Views.Edit, model) })); }
public void EditActivity(EditActivityModel editActivityModel) { var activity = _context.Set <Activity>().FirstOrDefault(a => a.ActivityId == editActivityModel.ActivityId); activity.SetValues(editActivityModel.Name, editActivityModel.StartAt, editActivityModel.EndAt, editActivityModel.ActivityType); }
public virtual ActionResult Add(Guid eventId) { e = GetEvent(eventId); var model = new EditActivityModel { EventId = e.Id, TimeStamp = new ModelTime { Date = e.NowLocal } }; return(PartialView(MVC.Activity.Views.Edit, model)); }
public virtual ActionResult Edit(string EventName, Guid id) { try { e = GetEvent(EventName); a = e.IndependentActivities.Where(x => x.Id == id).First(); } catch (Exception) { throw new HttpException(404, "Activity not found"); } var model = new EditActivityModel() { Id = a.Id, EventId = e.Id, Title = a.Title, TimeStamp = new ModelTime { Date = a.TimeStampLocal } }; return(PartialView(MVC.Activity.Views.Edit, model)); }
public ActionResult Edit(EditActivityModel editActivityModel) { _activityService.EditActivity(editActivityModel); return(RedirectToAction("Index")); }
public ActionResult Edit(EditActivityModel editActivityModel) { _bus.Send(editActivityModel); return(RedirectToAction("Index")); }