예제 #1
0
        public async Task <Result <RoomResultResponse> > Handle(AddRoomCommand request, CancellationToken cancellationToken)
        {
            using (_queueUnitOfWork)
            {
                try
                {
                    Rooms rm = new Rooms();
                    rm.RoomName    = request.RoomName;
                    rm.DisplayName = request.DisplayName;
                    rm.CreateDate  = DateTime.Now;
                    rm.CreatedBy   = request.CreatedBy;
                    rm.Active      = request.Active;
                    rm.DeleteFlag  = request.DeleteFlag;
                    rm.Description = request.Description;

                    await _queueUnitOfWork.Repository <Rooms>().AddAsync(rm);

                    await _queueUnitOfWork.SaveAsync();

                    return(Result <RoomResultResponse> .Valid(new RoomResultResponse()
                    {
                        Id = rm.Id,
                        Message = "The room has been added successfully"
                    }));
                }
                catch (Exception e)
                {
                    Log.Error(e.Message);
                    return(Result <RoomResultResponse> .Invalid(e.Message));
                }
            }
        }
예제 #2
0
 /// <summary>
 /// Creates a new instance of a job view model
 /// </summary>
 public JobVM()
 {
     // Initialize job commands
     CreateProposalCommand = new CreateProposalCommand(this);
     LoadCommand           = new LoadCommand(this);
     AddRoomCommand        = new AddRoomCommand(this);
     ToggleDisplayCommand  = new ToggleDisplayCommand(this);
 }
예제 #3
0
 public Guid AddRoom(bool tv, bool seperateToilet, Bathroom bathroom, Dimensions dimensions, params Bed[] beds)
 {
     var command = new AddRoomCommand(tv, seperateToilet, bathroom, dimensions, beds);
     var result = _processor.ProcessCommand(command);
     if (result.EventsWereEmitted)
     {
         return command.CreatedGuid;
     }
     throw new CreationFailedException(command.CreatedGuid, typeof (IRoom));
 }
예제 #4
0
 public Guid AddRoom(IRoom room)
 {
     var command = new AddRoomCommand(room);
     var result = _processor.ProcessCommand(command);
     if (result.EventsWereEmitted)
     {
         return command.CreatedGuid;
     }
     throw new CreationFailedException(command.CreatedGuid, typeof (IRoom));
 }
예제 #5
0
        public async Task <IActionResult> AddRooms([FromBody] AddRoomCommand command)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState.Values.Select(x => x.Errors)));
            }

            var response = await _mediator.Send(command, HttpContext.RequestAborted);

            if (!response.IsValid)
            {
                return(BadRequest(response));
            }

            return(Ok(response.Value));
        }
예제 #6
0
        public async Task <ActionResult> Create(AddRoomCommand addRoomCommand)
        {
            var ok = false;

            using (var httpClient = new HttpClient())
            {
                string      json    = JsonConvert.SerializeObject(addRoomCommand);
                HttpContent content = new StringContent(json, System.Text.Encoding.UTF8,
                                                        "application/json");
                Console.WriteLine("json " + json);
                using var response = await httpClient.PostAsync(_configuration.GetSection ("apiUrl").Value + "/rooms/Add", content);

                Console.WriteLine(await response.Content.ReadAsStringAsync());
                if (response.StatusCode == HttpStatusCode.OK)
                {
                    ok = true;
                }
            }
            return(RedirectToAction(""));
        }
        public AccomodationManagementViewModel()
        {
            _accomodationRepository = DataManagementService.Instance.MainRepository.AccomodationRepository;
            _locationRepository     = DataManagementService.Instance.MainRepository.LocationRepository;

            _accomodationFactory  = new AccomodationFactory();
            _accomodation         = _accomodationFactory.BuildAccomodation(_acomodationType);
            _selectedAccomodation = _accomodationFactory.BuildAccomodation(_acomodationType);

            _roomFactory  = new RoomFactory();
            _room         = _roomFactory.BuildRoom(_roomType);
            _selectedRoom = _roomFactory.BuildRoom(_roomType);

            _addAccomodationCommand    = new AddAccomodationCommand(this);
            _deleteAccomodationCommand = new DeleteAccomodationCommand(this);
            _editAccomodationCommand   = new EditAccomodationCommand(this);
            _saveAccomodationCommand   = new SaveAccomodationCommand(this);
            _addRoomCommand            = new AddRoomCommand(this);
            _editRoomCommand           = new EditRoomCommand(this);
            _saveRoomCommand           = new SaveRoomCommand(this);
        }
예제 #8
0
        // GET: Courses/Create
        public ActionResult Create()
        {
            AddRoomCommand room = new AddRoomCommand();

            return(View(room));
        }
예제 #9
0
 AddRoom([FromBody] AddRoomCommand command)
 => await this.Send(command);
예제 #10
0
 public async Task <IActionResult> Post([FromBody] AddRoomCommand request)
 {
     return(await CreateResponse(async() => await _mediator.Send(request)));
 }
예제 #11
0
        public async Task <IActionResult> Add(AddRoomCommand command)
        {
            int id = await Mediator.Send(command);

            return(Ok(id));
        }
예제 #12
0
 public void Initialize()
 {
     Beds           = 1;
     AddRoomCommand = new AddRoomCommand(this);
 }