Exemple #1
0
        public TaskLog Create(TaskLog item)
        {
            if (item.IsValid())
            {
                try
                {
                    db.TaskLogs.Add(item);
                    db.SaveChanges();

                    if (item.TaskID.HasValue)
                    {
                        item.Task = db.Tasks.Where(t => t.ID == item.TaskID.Value).Single();
                    }

                    MarkNotIsNew(item);
                    return(item);
                }
                catch (Exception ex)
                {
                    db.TaskLogs.Remove(item);
                    throw ex;
                }
            }
            else
            {
                throw new Exception("TaskLog is invalid");
            }
        }
Exemple #2
0
        public Requirement Create(Requirement item)
        {
            if (item.IsValid())
            {
                try
                {
                    db.Requirements.Add(item);
                    db.SaveChanges();

                    MarkNotIsNew(item);
                    return(item);
                }
                catch (Exception ex)
                {
                    db.Requirements.Remove(item);
                    throw ex;
                }
            }
            else
            {
                throw new Exception("Requirement is invalid");
            }
        }
Exemple #3
0
        public Feature Create(Feature item)
        {
            if (item.IsValid())
            {
                try
                {
                    db.Features.Add(item);
                    db.SaveChanges();

                    MarkNotIsNew(item);
                    return(item);
                }
                catch (Exception ex)
                {
                    db.Features.Remove(item);
                    throw ex;
                }
            }
            else
            {
                throw new Exception("Feature is invalid");
            }
        }
Exemple #4
0
        public TaskCheckIn Create(TaskCheckIn item)
        {
            try
            {
                db.TaskCheckIns.Add(item);
                db.SaveChanges();

                return(item);
            }
            catch (Exception ex)
            {
                db.TaskCheckIns.Remove(item);
                throw ex;
            }
        }
Exemple #5
0
        public CheckIn Create(CheckIn item)
        {
            if (item.IsValid())
            {
                //  to make sure that we don't re-insert the task
                if (item.TaskLog != null)
                {
                    long taskLogId = (item.TaskLog != null) ? item.TaskLog.ID : item.TaskLogID.Value;
                    item.TaskLog = db.TaskLogs.Where(t => t.ID == taskLogId).Single();

                    if (item.TaskCheckIns == null || item.TaskCheckIns.Count == 0)
                    {
                        item.TaskCheckIns = new List <TaskCheckIn> {
                            new TaskCheckIn {
                                TaskID = item.TaskLog.TaskID.Value
                            }
                        };
                    }
                }

                try
                {
                    db.CheckIns.Add(item);
                    db.SaveChanges();

                    MarkNotIsNew(item);
                    return(item);
                }
                catch (Exception ex)
                {
                    db.CheckIns.Remove(item);
                    throw ex;
                }
            }
            else
            {
                throw new Exception("CheckIn is invalid");
            }
        }
Exemple #6
0
        public CodeBranch Create(CodeBranch item)
        {
            if (item.IsValid())
            {
                try
                {
                    db.CodeBranches.Add(item);
                    db.SaveChanges();

                    return(item);
                }
                catch (Exception ex)
                {
                    db.CodeBranches.Remove(item);
                    throw ex;
                }
            }
            else
            {
                throw new Exception("CodeBranch is invalid");
            }
        }