Example #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");
            }
        }
Example #2
0
        public TaskLog Update(TaskLog item)
        {
            TaskLog updated = FetchAndUpdate(item);

            if (updated.IsValid())
            {
                try
                {
                    db.SaveChanges();
                    return(updated);
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
            else
            {
                throw new Exception("Requirement is invalid");
            }
        }