// [[1, 250, 'Unscheduled'], [2, 54, 'Sprint 1'], [3, 20, 'Sprint Banana'], [4, 0, 'Sprint Cross Reference'], [5, 8, 'Sprint Sammy']] private List<object> CreateTaskHoursPerSprintJsonList(Product product, int currentSprintId) { List<object> taskHoursPerSprintJsonList = new List<object>(); ScrumTimeEntities scrumTimeEntities = new ScrumTimeEntities(); TaskService taskService = new TaskService(scrumTimeEntities); decimal unassignedTaskHours = taskService.GetUnassignedTaskHours(product.ProductId); CheckSetYAxisMax(unassignedTaskHours); List<object> unassignedHoursList = new List<object>(); unassignedHoursList.Add(1); unassignedHoursList.Add(unassignedTaskHours); unassignedHoursList.Add("Unassigned"); taskHoursPerSprintJsonList.Add(unassignedHoursList); Ticks.Add(" "); SprintService sprintService = new SprintService(scrumTimeEntities); List<Sprint> mostRecentSprints = sprintService.GetMostRecentSprints(product.ProductId, currentSprintId, 4); int index = 2; foreach (Sprint recentSprint in mostRecentSprints) { List<object> sprintHoursList = new List<object>(); sprintHoursList.Add(index); sprintHoursList.Add(CalculateHoursForSprint(recentSprint)); sprintHoursList.Add(recentSprint.Name); taskHoursPerSprintJsonList.Add(sprintHoursList); Ticks.Add(" "); index++; } return taskHoursPerSprintJsonList; }
public Product SaveProduct(Product product) { if (product != null) { if (product.ProductId == 0) // this is new { _ScrumTimeEntities.AddToProducts(product); } else // the product exists { _ScrumTimeEntities.AttachTo("Products", product); ScrumTimeEntities freshScrumTimeEntities = new ScrumTimeEntities(_ScrumTimeEntities.Connection.ConnectionString); Product existingProduct = GetProductById(freshScrumTimeEntities, product.ProductId); if (existingProduct == null) { throw new Exception("The product no longer exists."); } _ScrumTimeEntities.ObjectStateManager.ChangeObjectState(product, System.Data.EntityState.Modified); } _ScrumTimeEntities.SaveChanges(); } return product; }
public static Product GetProductById(ScrumTimeEntities scrumTimeEntities, int id) { Product product = null; var results = from t in scrumTimeEntities.Products where t.ProductId == id select t; if (results.Count() > 0) product = results.First<Product>(); else product = new Product(); return product; }
/// <summary> /// Create a new Product object. /// </summary> /// <param name="productId">Initial value of the ProductId property.</param> /// <param name="name">Initial value of the Name property.</param> public static Product CreateProduct(global::System.Int32 productId, global::System.String name) { Product product = new Product(); product.ProductId = productId; product.Name = name; return product; }
/// <summary> /// Deprecated Method for adding a new object to the Products EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToProducts(Product product) { base.AddObject("Products", product); }
public virtual ActionResult New() { Product product = new Product() { Description = "", Name = "New Product" }; return PartialView(Views.Edit, CreateProductViewModel(product)); }
protected ProductViewModel CreateProductViewModel(Product product) { ProductViewModel productViewModel = new ProductViewModel() { ProductModel = product, IsCurrent = (product.ProductId == SessionHelper.GetCurrentProductId(User.Identity.Name, Session)) ? true : false }; return productViewModel; }
public virtual ActionResult Save(FormCollection collection) { try { string productId = collection.Get("id"); bool newProduct = false; if (productId == null || productId == "0") { productId = "0"; newProduct = true; } string name = collection.Get("name"); string description = collection.Get("description"); Product product = new Product() { ProductId = Int32.Parse(productId), Name = name, Description = description }; _ProductService.SaveProduct(product); if (newProduct) return RedirectToAction(Actions.ListByNameAlphabetical()); else return RedirectToAction(Actions.ReadOnly(Int32.Parse(productId))); } catch (Exception ex) { return View(); // TODO: Handle displaying the exception condition } }