public IActionResult Create(RentViewModel rentViewModel)
        {
            var canRent = rentApp.CanRentOffice(rentViewModel.Start_datetime, rentViewModel.End_datetime, rentViewModel.Room_id);

            if (canRent)
            {
                var RentDomain = mapper.Map <Rent>(rentViewModel);
                rentApp.Add(RentDomain);
                return(RedirectToAction("Index"));
            }
            else
            {
                TempData["Error"] = "Esta sala já se econtra reservada neste periodo.";
                return(RedirectToAction("Create"));
            }
        }
예제 #2
0
        public IActionResult Create([FromBody] RegisterViewModel registerViewModel)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    var rent = _mapper.Map <Domain.Entities.Rent>(registerViewModel);

                    _rentAppService.Add(rent);
                    return(StatusCode(200));
                }
                catch (Exception e)
                {
                    return(StatusCode(400, e.Message));
                }
            }
            else
            {
                return(StatusCode(400));
            }
        }