Example #1
0
        public IActionResult PutProfitPercent(string id, ProfitPercentViewModel profitPercent)
        {
            if (id != profitPercent.Id)
            {
                return(BadRequest());
            }


            try
            {
                _profitPercentService.Update(profitPercent);
                _profitPercentService.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ProfitPercentExists(id))
                {
                    new GenericResult(false, "Đã tồn tại tỷ lệ cược này!");
                }
                else
                {
                    new GenericResult(false, "Lỗi hệ thống!");
                }
            }

            return(NoContent());
        }
        public ProfitPercentViewModel Add(ProfitPercentViewModel profitPercentView)
        {
            var profitPercent = Mapper.Map <ProfitPercentViewModel, ProfitPercent>(profitPercentView);

            profitPercent.Id      = Guid.NewGuid().ToString();
            profitPercent.Name    = "Bảng " + new Random().Next(999);
            profitPercent.Status  = Status.Active;
            profitPercent.IsUsing = false;
            _profitPercentRepository.Add(profitPercent);

            return(profitPercentView);
        }
Example #3
0
        public ActionResult <ProfitPercentViewModel> PostProfitPercent(ProfitPercentViewModel profitPercent)
        {
            profitPercent.RegionStatus = RegionStatus.North;

            _profitPercentService.Add(profitPercent);

            try
            {
                _profitPercentService.SaveChanges();
            }
            catch (DbUpdateException)
            {
                if (ProfitPercentExists(profitPercent.Id))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtAction("GetProfitPercent", new { id = profitPercent.Id }, profitPercent));
        }
        public void Update(ProfitPercentViewModel profitPercentView)
        {
            var profit = Mapper.Map <ProfitPercentViewModel, ProfitPercent>(profitPercentView);

            _profitPercentRepository.Update(profit);
        }