Example #1
0
 /// <summary>
 /// Deprecated Method for adding a new object to the YearTargets EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToYearTargets(YearTarget yearTarget)
 {
     base.AddObject("YearTargets", yearTarget);
 }
Example #2
0
 /// <summary>
 /// Create a new YearTarget object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="actual">Initial value of the Actual property.</param>
 /// <param name="target1">Initial value of the Target1 property.</param>
 /// <param name="target2">Initial value of the Target2 property.</param>
 /// <param name="objectInfo">Initial value of the ObjectInfo property.</param>
 /// <param name="dealerManpowerId">Initial value of the DealerManpowerId property.</param>
 /// <param name="year">Initial value of the Year property.</param>
 public static YearTarget CreateYearTarget(global::System.Int32 id, global::System.Int32 actual, global::System.Int32 target1, global::System.Int32 target2, ObjectInfo objectInfo, global::System.Int32 dealerManpowerId, global::System.String year)
 {
     YearTarget yearTarget = new YearTarget();
     yearTarget.Id = id;
     yearTarget.Actual = actual;
     yearTarget.Target1 = target1;
     yearTarget.Target2 = target2;
     yearTarget.ObjectInfo = StructuralObject.VerifyComplexObjectIsNotNull(objectInfo, "ObjectInfo");
     yearTarget.DealerManpowerId = dealerManpowerId;
     yearTarget.Year = year;
     return yearTarget;
 }
Example #3
0
 public void UpdateYearTarget(IEnumerable<YearTarget> yearTargets)
 {
     var currentYear = DateTime.Now.ToString("yyyy");
     foreach (var yearTarget in yearTargets)
     {
         var oldTarget =
             _yearTargetRepo.Fetch().SingleOrDefault(x => x.ObjectInfo.DeletedDate == null && x.DealerManpowerId == yearTarget.DealerManpowerId && x.Year == currentYear);
         if (oldTarget != null)
         {
             oldTarget.Target1 = yearTarget.Target1;
             oldTarget.Target2 = yearTarget.Target2;
         }
         else
         {
             oldTarget = new YearTarget();
             oldTarget.DealerManpowerId = yearTarget.DealerManpowerId;
             oldTarget.Description = yearTarget.Description;
             oldTarget.Target1 = yearTarget.Target1;
             oldTarget.Target2 = yearTarget.Target2;
             oldTarget.Year = currentYear;
             _yearTargetRepo.Add(oldTarget);
         }
     }
     _yearTargetRepo.SaveChanges();
 }