Exemplo n.º 1
0
        public ActionResult Create(CreateAreaViewModel model)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(View(model));
                }

                var Area = _mapper.Map <Area>(model);

                var isSuccess = _areaRepository.Create(Area);
                if (!isSuccess)
                {
                    return(View(model));
                }


                return(RedirectToAction(nameof(Index)));
            }
            catch
            {
                ModelState.AddModelError("", "در ثبت اطلاعات مشکلی به وجود آمده است");
                return(View(model));
            }
        }
        public async Task <IActionResult> Create(CreateAreaViewModel model)
        {
            if (ModelState.IsValid)
            {
                // save
                await areaApi.CreateArea(model);

                return(RedirectToAction("Success"));
            }
            return(View(model));
        }
Exemplo n.º 3
0
        public async Task CreateArea(CreateAreaViewModel data)
        {
            using (HttpClient client = new HttpClient())
            {
                client.BaseAddress = new Uri(baseUrl);
                var httpContent         = new StringContent(JsonConvert.SerializeObject(data), Encoding.UTF8, "application/json");
                HttpResponseMessage msg = await client.PostAsync("area", httpContent);

                msg.EnsureSuccessStatusCode();
            }
        }
Exemplo n.º 4
0
 public void SetUpConverterCreateCommandShould()
 {
     this.createAreaViewModel = new CreateAreaViewModel
     {
         LayoutId    = 1,
         Description = "CreateAreaViewModelDescription",
         CoordX      = 2,
         CoordY      = 3
     };
     this.createEventAreaViewModel = new CreateEventAreaViewModel
     {
         CoordX      = 1,
         CoordY      = 2,
         Description = "CreateEventAreaViewModelDescription",
         EventId     = 11,
         Price       = 123142M
     };
     this.createEventViewModel = new CreateEventViewModel
     {
         Name        = "EventName1",
         Banner      = "EventBanner1",
         Description = "EventDescription1",
         RunTime     = TimeSpan.FromHours(1),
         StartAt     = new DateTime(2019, 1, 17, 18, 30, 0),
         LayoutId    = 1
     };
     this.createEventSeatViewModel = new CreateEventSeatViewModel
     {
         EventAreasId = 1,
         Row          = 2,
         Number       = 3,
         State        = 4
     };
     this.createLayoutViewModel = new CreateLayoutViewModel {
         VenueId = 1, Description = "LayoutDescription1"
     };
     this.createSeatViewModel = new CreateSeatViewModel {
         AreaId = 1, Row = 1, Number = 1
     };
     this.createVenueViewModel = new CreateVenueViewModel
     {
         Description = "VenueDescription1",
         Address     = "VenueAddress1",
         Phone       = "VenuePhone1"
     };
 }
Exemplo n.º 5
0
        public async Task <JsonResult> Post([FromBody] CreateAreaViewModel createViewModel)
        {
            var result = await this.Mediator.Send(createViewModel.ProjectedAs <PresenterCreateAreaCommand>());

            return(this.GetResult(result));
        }