Exemple #1
0
        public ActionResult <DealCreateDto> CreateDeal(DealCreateDto dealCreateDto)
        {
            var dealModel = _mapper.Map <Deals>(dealCreateDto);

            _repository.CreateDeal(dealModel);
            _repository.SaveChanges();

            var dealReadDto = _mapper.Map <DealReadDto>(dealModel);

            return(CreatedAtRoute(nameof(GetDealById), new { Id = dealReadDto.Id }, dealReadDto));
        }
        public async Task <IHttpActionResult> Register([FromBody] DealRequestViewModel dealModel)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            string         username = HttpContext.Current.User.Identity.Name;
            IdentityResult result   = await _repo.CreateDeal(username, dealModel);

            IHttpActionResult errorResult = GetErrorResult(result);

            return(errorResult == null?Ok() : errorResult);
        }
        private void Submit()
        {
            State = ViewModelState.Processing;

            var cmd = BuildCreateDealCommand();

            _dealRepository.CreateDeal(cmd)
            .SubscribeOn(Scheduler.Default)
            .ObserveOnDispatcher()
            .Subscribe(
                _ => { },
                ex =>
            {
                State = ViewModelState.Error(ex.ToString());
            },
                () =>
            {
                State = ViewModelState.Terminal;
            });
        }