Ejemplo n.º 1
0
        public bool DeleteTag(Guid tagId)
        {
            if (tagId == Guid.Empty)
                throw new FaultException("Unable to delete tag because the passed in id was empty");

            TaskrDataContext db = new TaskrDataContext(ConfigurationProvider.GetConnection("Taskr"));

            Tag tag = db.Tags.SingleOrDefault(t => t.Id == tagId);

            if (tag == null)
            {
                throw new FaultException(string.Format("Tag with id {0} not exist", tagId));
            }

            try
            {
                db.Tags.DeleteOnSubmit(tag);
                db.SubmitChanges();
                return true;
            }
            catch
            {
                return false;
            }
        }
Ejemplo n.º 2
0
        public TaskDTO GetTask(Guid taskId)
        {
            if (taskId == Guid.Empty)
                throw new FaultException("Unable to retrieve task because the passed in id was empty");

            TaskrDataContext db = new TaskrDataContext(ConfigurationProvider.GetConnection("Taskr"));
            return TaskDTO.StaticMapFrom(db.Tasks.SingleOrDefault(t => t.Id == taskId));
        }
Ejemplo n.º 3
0
        public IList<TagDTO> ListTags()
        {
            TaskrDataContext db = new TaskrDataContext(ConfigurationProvider.GetConnection("Taskr"));
            IList<TagDTO> result = new List<TagDTO>();

            foreach (var item in db.Tags.OrderBy(t => t.Label))
            {
                result.Add(TagDTO.StaticMapFrom(item));
            }

            return result;
        }
Ejemplo n.º 4
0
        public Guid SaveTag(TagDTO tag)
        {
            Guid tagId = Guid.Empty;

            if (tag == null)
                throw new FaultException("Unable to save null tag.");

            TaskrDataContext db = new TaskrDataContext(ConfigurationProvider.GetConnection("Taskr"));

            if (tag.Id == Guid.Empty)
            {
                Tag _tag = tag.MapTo();
                tagId = _tag.Id;
                db.Tags.InsertOnSubmit(_tag);
            }
            else
            {
                Tag _tag = db.Tags.SingleOrDefault(t => t.Id == tag.Id);
                tag.MapInto(_tag);
                tagId = _tag.Id;
            }

            db.SubmitChanges();
            return tagId;
        }
Ejemplo n.º 5
0
        public Guid SaveTask(TaskDTO task)
        {
            Guid taskId = Guid.Empty;

            if (task == null)
                throw new FaultException("Unable to save null task");

            TaskrDataContext db = new TaskrDataContext(ConfigurationProvider.GetConnection("Taskr"));

            if (task.Id == Guid.Empty)
            {
                //If a new task is created, instruct SaaSGrid to adjust the limit counter appriopriately.
                MeterStatus result = SubscriptionContext.Instance.IncrementLimitCounter(Constants.FeatureNumberOfTasks);

                if (MeterStatus.NotExhausted == result)
                {
                    try
                    {
                        Task _task = task.MapTo();
                        db.Tasks.InsertOnSubmit(_task);
                        db.SubmitChanges();
                        taskId = _task.Id;
                    }
                    catch
                    {
                        SubscriptionContext.Instance.DecrementLimitCounter(Constants.FeatureNumberOfTasks);
                        throw;
                    }
                }
                else
                {
                    throw new LimiterExhaustedException
                    (
                        Constants.FeatureNumberOfTasks,
                        result,
                        Home.Resources.Task_MaximumLimitReached
                    );
                }
            }
            else
            {
                Task existingTask = db.Tasks.SingleOrDefault(t => t.Id == task.Id);
                task.MapInto(existingTask);
                db.SubmitChanges();
                taskId = existingTask.Id;
            }

            return taskId;
        }