Exemplo n.º 1
0
        public async Task <IActionResult> Update([FromBody] ExpCompanyGetDto GetDto, string Id)
        {
            try
            {
                var position = await _service.QueryByIdAsync(Id);

                var positions = await _service.QueryAsync(u => u.EnCode == GetDto.EnCode);

                if (positions.Count > 0 && position.EnCode != GetDto.EnCode)
                {
                    return(Ok(new { Status = true, Message = "此编码已存在,请重新修改" }));
                }

                GetDto.Id = Id;
                var result = await _service.Update(GetDto);

                if (result > 0)
                {
                    return(Ok(new { Status = true, Message = "修改成功" }));
                }
                return(Ok(new { Status = false, Message = "修改失败,请刷新后重试" }));
            }
            catch (Exception ex)
            {
                return(Ok(new { Status = false, Message = ex.ToString() }));
            }
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Add([FromBody] ExpCompanyGetDto GetDto)
        {
            try
            {
                var customers = await _service.QueryAsync();

                var customer = customers.Find(u => u.EnCode == GetDto.EnCode);
                if (customer != null)
                {
                    return(Ok(new { Status = true, Message = "此编码已存在,请重新输入" }));
                }
                var result = await _service.Insert(GetDto);

                if (result > 0)
                {
                    return(Ok(new { Status = true, Message = "添加成功" }));
                }
                return(Ok(new { Status = false, Message = "添加失败,请刷新后重试" }));
            }
            catch (Exception ex)
            {
                return(Ok(new { Status = false, Message = ex.ToString() }));
            }
        }