/// <summary> /// Determines whether the data posted for new cycle is valid. /// </summary> /// <param name="newCycle">The new cycle object.</param> /// <returns>Flag indicating whether the data is valid.</returns> public AddCycle IsNewCycleDataValid(AddCycle newCycle) { AddCycle validCycle = new AddCycle(); validCycle.Year = newCycle.Year; validCycle.Period = newCycle.Period; validCycle.StartDate = newCycle.StartDate; validCycle.CloseDate = newCycle.CloseDate; return validCycle; }
/// <summary> /// Add new cycle to the repository. /// </summary> /// <param name="newCycle">The new cycle to be added.</param> /// <param name="pfNumber">The pf number of user.</param> /// <returns> /// Flag indicating whether the operation was successful. /// </returns> public bool NewCycle(AddCycle newCycle, int pfNumber) { if (this.pcRules.IsPfNumberValid(pfNumber)) { if (this.pcRules.IsNewCycleDataValid(newCycle) != null) { PerformanceReviewCycle cycle = new PerformanceReviewCycle { Year = newCycle.Year, Period = newCycle.Period, Status = "Draft", StartDate = newCycle.StartDate, CloseDate = newCycle.CloseDate }; this.db.PerformanceReviewCycles.Add(cycle); this.db.SaveChanges(); return true; } else { return false; } } else { return false; } }