Exemple #1
0
        public OkObjectResult Put(string id, string sName, string sCode, string sType, string sDesc)
        {
            if (string.IsNullOrEmpty(id))
            {
                return(JsonRes.Fail("id无效"));
            }
            VsTallyType pExit = _tallyTypeService.QueryByID(id);

            if (pExit == null)
            {
                return(JsonRes.Fail("类型不存在"));
            }
            pExit.SName = sName;
            pExit.SCode = sCode;
            pExit.SDesc = sDesc;
            pExit.SType = sType;
            string error = "";
            int    res   = _tallyTypeService.TryUpdate(out error, pExit);

            if (res == 0)
            {
                return(JsonRes.Fail(pExit, error));
            }
            return(JsonRes.Success(pExit));
        }
Exemple #2
0
        public OkObjectResult Post(string sName, string sCode, string sType, string sDesc)
        {
            VsTallyType entity = new VsTallyType
            {
                Id    = System.Guid.NewGuid().ToString(),
                SName = sName,
                SCode = sCode,
                SDesc = sDesc,
                SType = sType,
            };
            string error = "";
            int    res   = _tallyTypeService.TryAdd(out error, entity);

            if (res == 0)
            {
                return(JsonRes.Fail(entity, error));
            }
            return(JsonRes.Success(entity));
        }
Exemple #3
0
        public OkObjectResult Delete(string id)
        {
            if (string.IsNullOrEmpty(id))
            {
                return(JsonRes.Fail("id无效"));
            }
            VsTallyType pExit = _tallyTypeService.QueryByID(id);

            if (pExit == null)
            {
                return(JsonRes.Fail("类型不存在"));
            }
            string error = "";
            int    res   = _tallyTypeService.TryDelete(out error, pExit);

            if (res == 0)
            {
                return(JsonRes.Fail(pExit, error));
            }
            return(JsonRes.Success(pExit));
        }