public bool EditCycle(EditCycle cycleUpdate, int pfNumber) { TransactionScope scope = new TransactionScope(); try { if (this.pcRules.IsPfNumberValid(pfNumber)) { using (scope) { PerformanceReviewCycle cycle = new PerformanceReviewCycle { Id = cycleUpdate.Id, Year = cycleUpdate.Year, Period = cycleUpdate.Period, StartDate = cycleUpdate.StartDate, CloseDate = cycleUpdate.CloseDate, Status = cycleUpdate.Status }; this.db.Entry(cycle).State = EntityState.Modified; this.db.SaveChanges(); scope.Complete(); } return true; } else { scope.Dispose(); return false; } } catch (DataException) { scope.Dispose(); return false; } catch (TransactionAbortedException) { scope.Dispose(); return false; } catch (TransactionException) { scope.Dispose(); return false; } catch (Exception) { scope.Dispose(); return false; } }
/// <summary> /// Determines whether cycle edit data is valid. /// </summary> /// <param name="cycleUpdate">The cycle being edited.</param> /// <returns> /// Flag indicating whether the data is valid for cycle edit. /// </returns> public bool IsCycleEditDataValid(EditCycle cycleUpdate) { try { if (cycleUpdate != null) { return true; } else { return false; } } catch (Exception) { return false; } }