public async Task <IActionResult> Add(LineDto dto)
        {
            var result = await lineService.Add(dto) > 0;

            return(Ok(new JsonResultDto <bool>
            {
                Data = result,
                Message = result ? null : "操作失败"
            }));
        }
        public async Task <IActionResult> Add(LineDto dto)
        {
            var result = await lineService.Add(dto);

            lineManager.Add(dto);
            return(Ok(new JsonResultDto <string>
            {
                Data = result,
                Message = string.IsNullOrEmpty(result) ? null : "操作失败"
            }));
        }
Ejemplo n.º 3
0
        public string AddLine([FromBody] AddLineRequest request)
        {
            CommonBaseInfo res = new CommonBaseInfo();

            if (request.empId <= 0)
            {
                res.StateCode = 500;
                res.ResultMsg = "empId必须大于0";
                return(JsonConvert.SerializeObject(res));
            }
            _repository.DeleteLineByEmpId(request.empId);
            Line workLine = new Line()
            {
                name        = "上班路线",
                empId       = request.empId,
                origin      = request.origin,
                destination = request.destination,
                publishTime = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss"),
                takeTime    = request.workTime,
                startPoint  = request.startPoint,
                endPoint    = request.endPoint
            };
            Line overLine = new Line()
            {
                name        = "下班路线",
                empId       = request.empId,
                origin      = request.destination,
                destination = request.origin,
                publishTime = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss"),
                takeTime    = request.overTime,
                startPoint  = request.endPoint,
                endPoint    = request.startPoint
            };

            _repository.Add(workLine);
            _repository.Add(overLine);
            res.StateCode = 200;
            res.ResultMsg = "success";
            return(JsonConvert.SerializeObject(res));
        }
Ejemplo n.º 4
0
        public async Task <IActionResult> Create(LineDto create)
        {
            if (_lineService.GetById(create.ID) != null)
            {
                return(BadRequest("Line ID already exists!"));
            }
            create.CreatedDate = DateTime.Now;
            if (await _lineService.Add(create))
            {
                return(NoContent());
            }

            throw new Exception("Creating the model name failed on save");
        }