示例#1
0
        public IActionResult RejectTask([FromBody] EvaluationRejectViewModel model)
        {
            IActionResult response;
            var           result = _evaluation.Reject(model);

            if (result.IsError)
            {
                response = BadRequest(result);
            }
            else
            {
                response = Ok(result);
            }
            return(response);
        }
        /// <summary>
        /// Reject evaluation task.
        /// </summary>
        /// <param name="model">The evaluation reject information.</param>
        /// <returns></returns>
        public ResultViewModel Reject(EvaluationRejectViewModel model)
        {
            var result = new ResultViewModel();

            using (TransactionScope scope = new TransactionScope())
            {
                var data = _unitOfWork.GetRepository <EvaluationAssign>().Get(x => x.EvaluationId == model.Id && x.AdUser == _token.AdUser).FirstOrDefault();
                if (data.IsAction.Value)
                {
                    result = UtilityService.InitialResultError(MessageValue.EvaluationRejectTaskIsAction, (int)System.Net.HttpStatusCode.BadRequest);
                }
                else
                {
                    data.IsReject     = true;
                    data.ReasonReject = model.Reason;
                    _unitOfWork.GetRepository <EvaluationAssign>().Update(data);
                    _unitOfWork.Complete(scope);
                }
            }
            return(result);
        }