Exemplo n.º 1
0
 /// <summary>
 /// Create a new SubTasks object.
 /// </summary>
 /// <param name="code">Initial value of the code property.</param>
 /// <param name="name">Initial value of the Name property.</param>
 /// <param name="workingDays">Initial value of the WorkingDays property.</param>
 public static SubTasks CreateSubTasks(global::System.Int32 code, global::System.String name, global::System.Int32 workingDays)
 {
     SubTasks subTasks = new SubTasks();
     subTasks.code = code;
     subTasks.Name = name;
     subTasks.WorkingDays = workingDays;
     return subTasks;
 }
Exemplo n.º 2
0
        public static int[] UpdatePageTasks(List<SubTasksView> itemsI, List<SubTasksView> itemsM, List<int> toDelete)
        {
            if (itemsM == null && itemsI == null && toDelete == null) return new int[0];
            List<SubTasks> inserted = new List<SubTasks>();
            using (SiteDbEntities context = new SiteDbEntities())
            {
                bool aChange = false;
                if (itemsI != null)
                {
                    foreach (SubTasksView item in itemsI)
                    {
                        SubTasks curr = new SubTasks() { Name = item.Name, idTask = item.FatherId.Value, WorkingDays = item.WorkingDays };
                        aChange = true;
                        context.SubTasks.AddObject(curr);
                        inserted.Add(curr);
                    }
                }
                if (itemsM != null)
                {
                    foreach (SubTasksView item in itemsM)
                    {
                        SubTasks curr = new SubTasks() { Name = item.Name, code = item.Key.Value, idTask=item.FatherId.Value, WorkingDays=item.WorkingDays};
                        context.SubTasks.Attach(curr);
                        context.ObjectStateManager.ChangeObjectState(curr, System.Data.EntityState.Modified);
                        aChange = true;
                    }
                }
                if (toDelete != null)
                {
                    foreach (int key in toDelete)
                    {
                        SubTasks curr = new SubTasks() { code = key };
                        context.SubTasks.Attach(curr);
                        context.ObjectStateManager.ChangeObjectState(curr, System.Data.EntityState.Deleted);
                        aChange = true;
                    }
                }
                if (aChange)
                {
                    try
                    {
                        context.SaveChanges();

                    }
                    catch
                    {
                    }
                    return inserted.Select(m => m.code).ToArray();
                }
                else return new int[0];
            }
        }
Exemplo n.º 3
0
 /// <summary>
 /// Deprecated Method for adding a new object to the SubTasks EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToSubTasks(SubTasks subTasks)
 {
     base.AddObject("SubTasks", subTasks);
 }