Ejemplo n.º 1
0
        public ContractTimeline Update(ContractTimeline e)
        {
            //var r = Get(e.ID);
            //if (r != null)
            //{
            //    r.FromDate = e.FromDate;
            //    r.ToDate = e.ToDate;

            //    if (ValidConflictTimeline(r))
            //    {
            //        Save();
            //        e = r;
            //    }
            //}
            //return e;

            DB.ContractTimelines.Attach(e);
            if (ValidConflictTimeline(e))
            {
                DB.ObjectStateManager.ChangeObjectState(e, System.Data.EntityState.Modified);
                Save();
            }

            return e;
        }
Ejemplo n.º 2
0
        public ContractTimeline Add(int contractID, int timeCount, string timeUnit)
        {
            timeCount = timeCount < 1 ? 1 : timeCount;
            ContractRepository contractRepo = new ContractRepository() { DB = DB };
            Contract contract = contractRepo.Get(contractID);

            ContractTimeline lastContractTimeline = contract.ContractTimelines.OrderByDescending(r => r.Order).FirstOrDefault();

            ContractTimeline newContractTimeline = new ContractTimeline();

            if (lastContractTimeline == null)
            {
                newContractTimeline.Order = 1;
                newContractTimeline.FromDate = contract.SignedDate.HasValue ? contract.SignedDate : DateTime.Now.Date;
            }
            else
            {
                newContractTimeline.Order = lastContractTimeline.Order + 1;
                newContractTimeline.FromDate = lastContractTimeline.ToDate.Value.AddDays(1);
            }

            if (timeUnit.ToLower() == "day")
            {
                newContractTimeline.ToDate = newContractTimeline.FromDate.Value.AddDays(timeCount).AddDays(-1);
            }
            else if (timeUnit.ToLower() == "month")
            {
                newContractTimeline.ToDate = newContractTimeline.FromDate.Value.AddMonths(timeCount).AddDays(-1);
            }

            newContractTimeline.ContractID = contractID;

            DB.AddToContractTimelines(newContractTimeline);

            Save();

            return newContractTimeline;
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Deprecated Method for adding a new object to the ContractTimelines EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToContractTimelines(ContractTimeline contractTimeline)
 {
     base.AddObject("ContractTimelines", contractTimeline);
 }
Ejemplo n.º 4
0
        public bool ValidConflictTimeline(ContractTimeline e)
        {
            bool isValid = true;

            ContractTimeline preTimeline = Get(e.ContractID, e.Order - 1);
            ContractTimeline nextTimeline = Get(e.ContractID, e.Order + 1);

            if (preTimeline != null)
            {
                if (preTimeline.IsJoin(e))
                    isValid = false;
            }

            if (nextTimeline != null)
            {
                if (nextTimeline.IsJoin(e))
                    isValid = false;
            }

            return isValid;
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Create a new ContractTimeline object.
 /// </summary>
 /// <param name="id">Initial value of the ID property.</param>
 public static ContractTimeline CreateContractTimeline(global::System.Int32 id)
 {
     ContractTimeline contractTimeline = new ContractTimeline();
     contractTimeline.ID = id;
     return contractTimeline;
 }