Esempio n. 1
0
        public JsonResult Save(OperationEditViewModel model)
        {
            var result = new JsonResultBO(true);

            try
            {
                if (ModelState.IsValid)
                {
                    if (model.Id <= 0)
                    {
                        Operation entity = new Operation()
                        {
                            Name     = model.Name,
                            Code     = model.Code,
                            URL      = model.URL,
                            IsShow   = model.IsShow,
                            Order    = model.Order.ToNumber <int>(),
                            ModuleId = model.ModuleId
                        };
                        _operationService.Create(entity);
                        _Ilog.InfoFormat("Thêm mới thao tác {0}", model.Name);
                    }
                    else
                    {
                        Operation entity = _operationService.GetById(model.Id);
                        entity.Name   = model.Name;
                        entity.Code   = model.Code;
                        entity.URL    = model.URL;
                        entity.IsShow = model.IsShow;
                        entity.Order  = model.Order.ToNumber <int>();
                        _operationService.Update(entity);

                        _Ilog.InfoFormat("Cập nhật thao tác {0}", model.Name);
                    }
                    return(Json(result));
                }
                result.Message = ModelState.GetErrors();
                result.Status  = false;
                return(Json(result));
            }
            catch (Exception ex)
            {
                result.Status  = false;
                result.Message = "Không cập nhật được";
                _Ilog.Error("Lỗi cập nhật thông tin Thao tác", ex);
            }
            return(Json(result));
        }
Esempio n. 2
0
        public IActionResult Post([FromBody] OperationDto model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            return(Ok(_operationService.Create(User.Identity.GetUserId(), model)));
        }
        public ActionResult Create(OperationViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            var modelBL = _mapper.Map <OperationModel>(model);

            _service.Create(modelBL);
            return(RedirectToAction("Index"));
        }
Esempio n. 4
0
        public ActionResult ResolveRequest(int id)//orderId
        {
            ApplicationUserVM user  = _accountService.GetByUserName(User.Identity.Name);
            OrderVM           order = _orderService.GetAll().Where(x => x.Id == id).FirstOrDefault();

            if (order != null)
            {
                ApplicationUserVM currentUser = user;
                ApplicationUserVM requestUser = _accountService.GetById(order.UserId);
                int points = order.Post.Subcategory.Points;
                if (requestUser != null)
                {
                    if (requestUser.Points >= points)
                    {
                        requestUser.Points -= points;
                        _accountService.UpdateUserPoints(requestUser);
                        _operationService.Create(CreateOperation(true, points, requestUser.Id));
                        currentUser.Points += points;
                        _accountService.UpdateUserPoints(currentUser);
                        _operationService.Create(CreateOperation(false, points, requestUser.Id));
                        _orderService.Delete(order.Id);
                        TempData["Message"] = "Операция произведена успешно";
                    }
                    else
                    {
                        TempData["Message"] = "Вы не можете совершить обмен с данным пользователем";
                    }
                }
                else
                {
                    TempData["Message"] = "Такого пользователя не существует";
                }
            }
            else
            {
                TempData["Message"] = "Такого запроса не существует";
            }

            return(RedirectToAction("ResponsePost"));
        }
Esempio n. 5
0
        public void Post([FromBody] OperationData model)
        {
            var operationPL = _mapper.Map <OperationModel>(model);

            _service.Create(operationPL);
        }
Esempio n. 6
0
 public OperationEntity Create([FromBody] OperationEntity OperationEntity)
 {
     return(OperationService.Create(EmployeeEntity, OperationEntity));
 }