public ActionResult Edit(int id = 0)
 {
     var entity = _activityRepository.Entities.SingleOrDefault(x => x.ID == id);
     if (entity == null)
     {
         entity = new Activity();
     }
     if (id == 0)
     {
         entity.StartDate = DateTime.Now;
         entity.FinishDate = DateTime.Now.AddHours(2);
     }
     var viewModel = new ActivityViewModel();
     viewModel.Activity = entity;
     return View(viewModel);
 }
		private void detach_Activities(Activity entity)
		{
			this.SendPropertyChanging();
			entity.ActivityStatus = null;
		}
		private void attach_Activities(Activity entity)
		{
			this.SendPropertyChanging();
			entity.User = this;
		}
 partial void DeleteActivity(Activity instance);
 partial void UpdateActivity(Activity instance);
 partial void InsertActivity(Activity instance);
        public ActionResult Remove(Activity model)
        {
            try
            {
                if (_activityRepository.Remove(model))
                {
                    return RedirectToAction("Grid", "ActivityGrid");
                }
            }
            catch (Exception ex)
            {
                ViewBag.ErrorMessage = ex.Message;
                return View(model);
            }

            ViewBag.ErrorMessage = "Не удалось удалить запись";
            return View(model);
        }