Ejemplo n.º 1
0
        public async Task <IActionResult> Create(CreateTravelViewModel model)
        {
            model.UserName = User.Identity.Name;
            string id = await _travelService.CreateAsync(model);

            return(RedirectToAction("Details", "Travel", new { rowKey = id, PartitionKey = User.Identity.Name }));
        }
Ejemplo n.º 2
0
        public async Task <string> CreateAsync(CreateTravelViewModel model)
        {
            var         id      = Guid.NewGuid();
            TravelModel tvModel = new TravelModel(model.UserName, id.ToString())
            {
                Title   = model.Title,
                Content = model.Content,
            };
            await _storageTableClient.CreateAsync <TravelModel>(tvModel);

            return(id.ToString());
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> Create([FromBody] CreateTravelViewModel vm)
        {
            var result = await _services.CreateAsync(_mapper.Map <TravelDTO>(vm));

            if (result.IsValid)
            {
                await _systemAuditService.AuditAsync(User.GetEmail(), _accessor.GetIp(), Operations.Insert, Tables.Event);

                return(CreatedAtRoute("GetTravel", new { version = "1.0", controller = "Travel", id = result.Result }, vm));
            }
            return(UnprocessableEntity(result.ErrorsList));
        }
Ejemplo n.º 4
0
        public async Task <IActionResult> Create(CreateTravelViewModel vm)
        {
            if (ModelState.IsValid)
            {
                var result = await _services.CreateAsync(_mapper.Map <TravelDTO>(vm));

                if (result.IsValid)
                {
                    await _systemAuditService.AuditAsync(User.GetEmail(), _accessor.GetIp(), Operations.Insert, Tables.Event);

                    return(RedirectToAction("Index"));
                }
                TempData["ErrorsList"] = result.ErrorsList;
            }
            return(View(vm));
        }
Ejemplo n.º 5
0
        public async Task <IActionResult> Create([FromBody] CreateTravelViewModel vm)
        {
            if (ModelState.IsValid)
            {
                var result = await _services.CreateAsync(_mapper.Map <TravelDTO>(vm));

                if (result.IsValid)
                {
                    await _systemAuditService.AuditAsync(User.GetEmail(), _accessor.GetIp(), Operations.Insert, Tables.Event);

                    return(Ok(result));
                }
                return(BadRequest(result));
            }
            return(BadRequest());
        }
Ejemplo n.º 6
0
 public async Task <string> CreateAsync(CreateTravelViewModel model)
 {
     return(await _azureStorageService.CreateAsync(model));
 }