Ejemplo n.º 1
0
		public TaskTagEntity Update (TaskTagEntity entity)
		{
			try
            {
                _tasktagRepository.Update(entity);
                return entity;
            }
            catch (Exception e)
            {
				_log.Error(e,"数据库操作出错");
                return null;
            }
		}
Ejemplo n.º 2
0
		public bool Delete(TaskTagEntity entity)
		{
			try
            {
                _tasktagRepository.Delete(entity);
                return true;
            }
            catch (Exception e)
            {
				_log.Error(e,"数据库操作出错");
                return false;
            }
		}
Ejemplo n.º 3
0
        public HttpResponseMessage AddTaskTag([FromBody]TaskTagModel taskTagModel)
        {
            if (!string.IsNullOrWhiteSpace(taskTagModel.Name))
            {
                Regex reg = new Regex(@"^[^ %@#!*~&',;=?$\x22]+$");
                var m = reg.IsMatch(taskTagModel.Name);
                if (!m)
                {
                    return PageHelper.toJson(PageHelper.ReturnValue(false, "目标名称存在非法字符!"));
                }
                if (!string.IsNullOrEmpty(taskTagModel.Describe))
                {
                    var m1 = reg.IsMatch(taskTagModel.Describe);

                    if (!m1)
                    {
                        return PageHelper.toJson(PageHelper.ReturnValue(false, "描述存在非法字符!"));
                    }
                }
                var model = new TaskTagEntity
                {
                    Id = taskTagModel.Id,
                    Name = taskTagModel.Name,
                    Describe = taskTagModel.Describe,
                    Value = taskTagModel.Value
                };
                var mo1 = new TaskTagSearchCondition
               {
                   NameRe = taskTagModel.Name
               };
                if (taskTagModel.Type == "add")
                {
                    int taskTagCount = _taskTagService.GetTaskTagCount(mo1);
                    if (taskTagCount > 0)
                    { return PageHelper.toJson(PageHelper.ReturnValue(false, "名称重复,请更换")); }
                    else
                    {
                        try
                        {
                            _taskTagService.Create(model);
                            return PageHelper.toJson(PageHelper.ReturnValue(true, "添加成功"));
                        }
                        catch (Exception)
                        {
                            return PageHelper.toJson(PageHelper.ReturnValue(false, "添加失败"));
                        }
                    }
                }
                if (taskTagModel.Type == "edit")
                {
                    try
                    {
                        _taskTagService.Update(_taskTagService.GetTaskTagById(taskTagModel.Id));
                        return PageHelper.toJson(PageHelper.ReturnValue(true, "操作成功"));
                    }
                    catch (Exception)
                    {
                        return PageHelper.toJson(PageHelper.ReturnValue(false, "添加失败"));
                    }
                }
            }
            return PageHelper.toJson(PageHelper.ReturnValue(false, "类型名称不能为空"));
        }