Example #1
0
        public Release SaveRelease(Release release)
        {
            if (release != null)
            {
                if (release.ReleaseId == 0)  // this is new
                {
                    _ScrumTimeEntities.AddToReleases(release);
                }
                else  // the release exists
                {
                    _ScrumTimeEntities.AttachTo("Releases", release);

                    ScrumTimeEntities freshScrumTimeEntities =
                        new ScrumTimeEntities(_ScrumTimeEntities.Connection.ConnectionString);
                    Release existingRelease = GetReleaseById(freshScrumTimeEntities, release.ReleaseId);
                    if (existingRelease == null)
                    {
                        throw new Exception("The release no longer exists.");
                    }
                    _ScrumTimeEntities.ObjectStateManager.ChangeObjectState(release, System.Data.EntityState.Modified);
                }
                _ScrumTimeEntities.SaveChanges();
            }
            return release;
        }
Example #2
0
 public static Release GetReleaseById(ScrumTimeEntities scrumTimeEntities, int id)
 {
     Release release = null;
     var results = from t in scrumTimeEntities.Releases
                   where t.ReleaseId == id
                   select t;
     if (results.Count() > 0)
         release = results.First<Release>();
     else
         release = new Release();
     return release;
 }
Example #3
0
        // [['09/20/2010', 0, 'Release 0.6'], ['09/20/2010', 3, 'Release 0.6']]
        private List<object> CreateReleaseJsonList(int sprintCount, Release release)
        {
            sprintCount = (sprintCount < 1) ? 1 : sprintCount;
            List<object> releaseJsonList = new List<object>();

            List<object> releaseTopDetailsList = new List<object>();
            releaseTopDetailsList.Add(release.Target.ToString("MM/dd/yyyy"));
            releaseTopDetailsList.Add(0);
            releaseTopDetailsList.Add("Release " + release.Name);
            releaseJsonList.Add(releaseTopDetailsList);

            List<object> releaseBottomDetailsList = new List<object>();
            releaseBottomDetailsList.Add(release.Target.ToString("MM/dd/yyyy"));
            releaseBottomDetailsList.Add(sprintCount);
            releaseBottomDetailsList.Add("Release " + release.Name);
            releaseJsonList.Add(releaseBottomDetailsList);

            return releaseJsonList;
        }
 /// <summary>
 /// Create a new Release object.
 /// </summary>
 /// <param name="releaseId">Initial value of the ReleaseId property.</param>
 /// <param name="name">Initial value of the Name property.</param>
 /// <param name="target">Initial value of the Target property.</param>
 /// <param name="productId">Initial value of the ProductId property.</param>
 public static Release CreateRelease(global::System.Int32 releaseId, global::System.String name, global::System.DateTime target, global::System.Int32 productId)
 {
     Release release = new Release();
     release.ReleaseId = releaseId;
     release.Name = name;
     release.Target = target;
     release.ProductId = productId;
     return release;
 }
 /// <summary>
 /// Deprecated Method for adding a new object to the Releases EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToReleases(Release release)
 {
     base.AddObject("Releases", release);
 }
 public virtual ActionResult New(int productId)
 {
     // TODO: May want to lookup the product id to ensure that it is valid
     Release release = new Release()
     {
         ProductId = productId,
         Name = "---",
         Target = DateTime.Today
     };
     return PartialView(Views.Edit, release);
 }
        public virtual ActionResult Save(FormCollection collection)
        {
            try
            {
                string id = collection.Get("releaseId");
                string productId = collection.Get("productId");
                bool newRelease = false;
                if (id == null || id == "0")
                {
                    id = "0";
                    newRelease = true;
                }
                string name = collection.Get("name");
                string description = collection.Get("description");
                string target = collection.Get("target");
                // TODO:  Validate the release data before saving
                // TODO:  Set the correct product id
                Release release = new Release()
                {
                    ReleaseId = Int32.Parse(id),
                    ProductId = Int32.Parse(productId),
                    Name = name,
                    Description = description,
                    Target = DateTime.Parse(target)
                };
                _ReleaseService.SaveRelease(release);

                if (newRelease)
                    return RedirectToAction(Actions.ListByTargetDateDesc(Int32.Parse(productId)));
                else
                    return RedirectToAction(Actions.ReadOnly(Int32.Parse(id)));
            }
            catch (Exception ex)
            {
                return View();  // TODO:  Handle displaying the exception condition
            }
        }