示例#1
0
        public async Task <JsonResponse> Insert([FromBody] Area area)
        {
            JsonResponse result = new JsonResponse();
            var          list   = await _context.Area.FirstOrDefaultAsync(m => m.Name == area.Name);

            if (list != null)
            {
                result.Msg    = "地区已存在";
                result.Status = ErrorCode.Unknown;
                return(result);
            }
            else
            {
                area.Id   = 0;
                area.Date = DateTime.Now;
                try
                {
                    _context.Add(area);
                    _context.SaveChanges();
                    result.Msg    = "地区新增成功";
                    result.Status = ErrorCode.Sucess;
                    return(result);
                }
                catch
                {
                    result.Msg    = "地区新增失败";
                    result.Status = ErrorCode.Unknown;
                    return(result);
                }
            }
        }
示例#2
0
        public async Task <JsonResponse> Insert([FromBody]  Contract contract)
        {
            JsonResponse result = new JsonResponse();
            var          list   = await _context.Contract.FirstOrDefaultAsync(m => m.ContractNumber == contract.ContractNumber);

            if (list != null)
            {
                result.Msg    = "合同信息已存在";
                result.Status = ErrorCode.Unknown;
                return(result);
            }
            else
            {
                contract.Id   = 0;
                contract.Date = DateTime.Now;
                try
                {
                    _context.Add(contract);
                    _context.SaveChanges();
                    result.Msg    = "合同信息新增成功";
                    result.Status = ErrorCode.Sucess;
                    return(result);
                }
                catch
                {
                    result.Msg    = "合同信息新增失败";
                    result.Status = ErrorCode.Unknown;
                    return(result);
                }
            }
        }
示例#3
0
        public async Task <JsonResponse> Insert([FromBody] Goods goods)
        {
            JsonResponse result = new JsonResponse();
            var          list   = await _context.Goods.FirstOrDefaultAsync(m => m.GoodsName == goods.GoodsName);

            if (list != null)
            {
                result.Msg    = "品类已存在";
                result.Status = ErrorCode.Unknown;
                return(result);
            }
            else
            {
                goods.Id   = 0;
                goods.Date = DateTime.Now;
                try
                {
                    _context.Add(goods);
                    _context.SaveChanges();
                    result.Msg    = "品类新增成功";
                    result.Status = ErrorCode.Sucess;
                    return(result);
                }
                catch
                {
                    result.Msg    = "品类新增失败";
                    result.Status = ErrorCode.Unknown;
                    return(result);
                }
            }
        }
示例#4
0
        public async Task <JsonResponse> Insert([FromBody] Carmanage carmanage)
        {
            JsonResponse result = new JsonResponse();

            carmanage.Id   = 0;
            carmanage.Date = DateTime.Now;
            try
            {
                _context.Add(carmanage);
                _context.SaveChanges();
                result.Msg    = "车辆信息新增成功";
                result.Status = ErrorCode.Sucess;
                return(result);
            }
            catch
            {
                result.Msg    = "车辆信息新增失败";
                result.Status = ErrorCode.Unknown;
                return(result);
            }
        }