Exemplo n.º 1
0
        public ActionResult Create(DayModeCreateRequest request)
        {
            try
            {
                #region check model
                //if (!ModelState.IsValid)
                //{
                //    var modelState = ModelState.FirstOrDefault();
                //    var error = modelState.Value.Errors.FirstOrDefault().ErrorMessage;
                //    throw ApiException.Get(false, error, ResultEnum.ModelError, HttpStatusCode.BadRequest);
                //}
                #endregion

                dayModeService.CreateDayMode(request);
                response = BaseResponse <dynamic> .Get(true, ConstantManager.CreateSuccess(""), null, ResultEnum.Success);
            }
            catch (ApiException e)
            {
                result.StatusCode = e.StatusCode;
                response          = BaseResponse <dynamic> .Get(e.Success, e.ErrorMessage, null, e.ErrorStatus);

                result = new JsonResult(response);
            }
            catch (Exception e)
            {
                result.StatusCode = (int)HttpStatusCode.InternalServerError;
                response          = BaseResponse <dynamic> .Get(false, ConstantManager.Fail("Day Mode : ") + e.ToString(), null, ResultEnum.InternalError);
            }
            result = new JsonResult(response);
            return(result);
        }
Exemplo n.º 2
0
        public ActionResult Add(List <ShiftRegisterBasic> request)
        {
            try
            {
                #region check model
                if (!ModelState.IsValid)
                {
                    var modelState = ModelState.FirstOrDefault();
                    var error      = modelState.Value.Errors.FirstOrDefault().ErrorMessage;
                    throw ApiException.Get(false, error, ResultEnum.ModelError, HttpStatusCode.BadRequest);
                }
                #endregion

                shiftRegisterService.RegistShift(request);
                response = BaseResponse <dynamic> .Get(false, ConstantManager.CreateSuccess("Shift Register :"), null, ResultEnum.Success);
            }
            catch (ApiException e)
            {
                result.StatusCode = e.StatusCode;
                response          = BaseResponse <dynamic> .Get(e.Success, e.ErrorMessage, null, e.ErrorStatus);

                result = new JsonResult(response);
            }
            catch (Exception e)
            {
                result.StatusCode = (int)HttpStatusCode.InternalServerError;
                response          = BaseResponse <dynamic> .Get(false, ConstantManager.Fail("Shift Register : ") + e.ToString(), null, ResultEnum.InternalError);
            }
            result = new JsonResult(response);
            return(result);
        }