Exemple #1
0
        public ActionResult Index([FromBody] TalentPriceEditVM modelVM)
        {
            try
            {
                var    curUser = accountUtil.GetCurrentUser(User);
                Talent model   = TalentService.GetByID(modelVM.id);
                if (model == null || !model.UserID.Equals(curUser.ID))
                {
                    throw new Exception("Талант не найден");
                }

                if (ModelState.IsValid && IsCorrectPriceProvided(modelVM.price))
                {
                    model.Price = modelVM.price;

                    TalentService.Update(model, curUser.ID);

                    return(Ok());
                }
                else
                {
                    throw new Exception("Указаны некорректные данные");
                }
            }
            catch (Exception ex)
            {
                return(CustomBadRequest(ex));
            }
        }
Exemple #2
0
        public ActionResult <TalentPriceEditVM> Index()
        {
            try
            {
                var    curUser = accountUtil.GetCurrentUser(User);
                Talent model   = TalentService.GetByUserID(curUser.ID);
                if (model == null)
                {
                    throw new Exception("Талант не найден");
                }

                TalentPriceEditVM modelVM = new TalentPriceEditVM(model);

                return(Ok(modelVM));
            }
            catch (Exception ex)
            {
                return(CustomBadRequest(ex));
            }
        }