public JsonResult CreateActivity(ActivityModel model)
        {
            if (!ModelState.IsValid)
            {
                return Json(new
                {
                    Result = "ERROR",
                    Message = "Form is not valid! " +
                    "Please correct it and try again."
                });
            }

            try
            {
                JourListDMContainer dm = new JourListDMContainer();

                Activity newActivity = new Activity();
                newActivity.Points = model.Points;
                newActivity.Description = model.Description;
                newActivity.Unit = dm.Units.Single(z => z.Id == model.UnitId);
                newActivity.Quantity = model.Quantity;
                dm.AddToActivities(newActivity);
                dm.SaveChanges();

                model.Id = newActivity.Id;

                return Json(new { Result = "OK", Record = model });
            }
            catch (Exception e)
            {
                return Json(new { Result = "ERROR", Message = e.Message });
            }
        }
 public ActivityModel(Activity activity)
 {
     // TODO: Complete member initialization
     this.Id = activity.Id;
     this.Description = activity.Description;
     this.Points = activity.Points;
     this.UnitId = activity.Unit.Id;
     this.Active = activity.Active;
     this.Quantity = activity.Quantity;
 }
 /// <summary>
 /// Create a new Activity object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="description">Initial value of the Description property.</param>
 public static Activity CreateActivity(global::System.Int64 id, global::System.String description)
 {
     Activity activity = new Activity();
     activity.Id = id;
     activity.Description = description;
     return activity;
 }
 private void set(ActivityLog log, Activity act)
 {
     if (log != null)
     {
         this.LogId = log.Id;
         this.Quantity = log.Quantity;
         this.unitid = log.Unit.Id;
         this.UnitList = new SelectList(log.Unit.UnitType.Units, "Id", "Description", this.sUnitId);
         this.Hyperlink = log.Hyperlink;
         this.Notes = log.Notes;
         this.Description = log.Activity.Description;
         this.JourId = log.Journal.Id;
      //               this.TotalPoints = (int)(act.Points * log.Quantity);
     }
     else
     {
         this.unitid = act.Unit.Id;
         this.UnitList = new SelectList(act.Unit.UnitType.Units, "Id", "Description", this.sUnitId);
     }
     this.ActId = act.Id;
     this.Description = act.Description;
     //            this.Points = act.Points;
 }
 /// <summary>
 /// Deprecated Method for adding a new object to the Activities EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToActivities(Activity activity)
 {
     base.AddObject("Activities", activity);
 }