public JsonResult UnassignMilestone(MilestoneInputModel obj) { var rep = new ReleaseRepository(); var release = rep.UnAssignMilestone(obj); return this.Json(release, JsonRequestBehavior.AllowGet); }
public Release UnAssignMilestone(MilestoneInputModel obj) { var conn = new SqlConnection("Data Source=localhost\\SQLENTERPRISE;Initial Catalog=Planner;Integrated Security=SSPI;MultipleActiveResultSets=true"); try { using (conn) { conn.Open(); var cmd = new SqlCommand("sp_unassign_milestone_from_release", conn); cmd.Parameters.Add("@ReleaseId", System.Data.SqlDbType.Int).Value = obj.PhaseId; cmd.Parameters.Add("@MilestoneId", System.Data.SqlDbType.Int).Value = obj.Id; SqlParameter returnParameter = cmd.Parameters.Add("RetVal", SqlDbType.Int); returnParameter.Direction = ParameterDirection.ReturnValue; cmd.CommandType = System.Data.CommandType.StoredProcedure; cmd.ExecuteNonQuery(); } return this.GetRelease(obj.PhaseId); } catch (Exception ex) { throw; } }
public JsonResult SaveMilestone(MilestoneInputModel obj) { var rep = new ReleaseRepository(); var resultRelease = rep.SaveMilestone(obj); var result = this.Json(resultRelease, JsonRequestBehavior.AllowGet); return result; }
public Milestone SaveMilestone(MilestoneInputModel obj) { var conn = new SqlConnection("Data Source=localhost\\SQLENTERPRISE;Initial Catalog=Planner;Integrated Security=SSPI;MultipleActiveResultSets=true"); int milestoneId = 0; try { using (conn) { conn.Open(); var cmd = new SqlCommand("sp_upsert_milestone", conn); cmd.Parameters.Add("@Id", System.Data.SqlDbType.Int).Value = obj.Id; cmd.Parameters.Add("@Title", System.Data.SqlDbType.VarChar).Value = obj.Title; cmd.Parameters.Add("@Description", System.Data.SqlDbType.VarChar).Value = obj.Description ?? ""; cmd.Parameters.Add("@Date", System.Data.SqlDbType.VarChar).Value = obj.Date.ToDateTimeFromDutchString(); cmd.Parameters.Add("@Time", System.Data.SqlDbType.VarChar).Value = obj.Time ?? ""; cmd.Parameters.Add("@PhaseId", System.Data.SqlDbType.Int).Value = obj.PhaseId; cmd.CommandType = System.Data.CommandType.StoredProcedure; var result = cmd.ExecuteScalar(); var newId = result == null ? 0 : int.Parse(result.ToString()); // it's an update (case 1) or an insert (case 2) milestoneId = newId == 0 ? obj.Id : newId; // completely renew the Deliverables for the Milestone as set in the client app var cmdDelCross = new SqlCommand(string.Format("Delete from MilestoneDeliverables where MilestoneId = {0}", milestoneId), conn); cmdDelCross.ExecuteNonQuery(); if (obj.Deliverables != null && obj.Deliverables.Count > 0) { var cmdInserMilestoneDeliverable = new SqlCommand("sp_insert_milestonedeliverable", conn); cmdInserMilestoneDeliverable.Parameters.Add("@MilestoneId", System.Data.SqlDbType.Int).Value = milestoneId; cmdInserMilestoneDeliverable.Parameters.Add("@DeliverableId", System.Data.SqlDbType.Int).Value = 0; /*cmdInserMilestoneDeliverable.Parameters.Add("@HoursRemaining", System.Data.SqlDbType.Int).Value = 0; cmdInserMilestoneDeliverable.Parameters.Add("@InitialEstimate", System.Data.SqlDbType.Int).Value = 0; cmdInserMilestoneDeliverable.Parameters.Add("@Owner", System.Data.SqlDbType.VarChar).Value = string.Empty; cmdInserMilestoneDeliverable.Parameters.Add("@State", System.Data.SqlDbType.VarChar).Value = string.Empty;*/ cmdInserMilestoneDeliverable.CommandType = System.Data.CommandType.StoredProcedure; foreach (var itm in obj.Deliverables) { cmdInserMilestoneDeliverable.Parameters["@DeliverableId"].Value = itm.Id; /*cmdInserMilestoneDeliverable.Parameters["@HoursRemaining"].Value = itm.HoursRemaining; cmdInserMilestoneDeliverable.Parameters["@InitialEstimate"].Value = itm.InitialHoursEstimate; cmdInserMilestoneDeliverable.Parameters["@Owner"].Value = itm.Owner ?? ""; cmdInserMilestoneDeliverable.Parameters["@State"].Value = itm.State ?? "";*/ cmdInserMilestoneDeliverable.ExecuteNonQuery(); } } } var rel = this.GetReleaseSummary(obj.PhaseId); this.GenerateStatusRecords(rel); var msrep = new MilestoneRepository(); var milestone = msrep.GetItemById(milestoneId); return milestone; } catch (Exception ex) { throw; } }