示例#1
0
        public ActionResult <AddRegistrationResource> GetAddRegistrationResourceSample()
        {
            var sample = new AddRegistrationResource()
            {
                ClientName     = "Bob Cobich",
                Phone          = "67843298",
                RoomId         = new Guid(),
                RegistrationId = new Guid(),
                Start          = DateTime.Now,
                End            = DateTime.Now
            };

            return(Ok(sample));
        }
示例#2
0
        public ActionResult <RegistrationDTO> Edit([FromBody] AddRegistrationResource resource)
        {
            var reg = _repository.GetRegistration(resource.RegistrationId);

            var client = _repository.GetOrAddClient(resource.ClientName, resource.Phone);

            var room = _repository.GetRoom(resource.RoomId);

            reg.ClientId     = client.Id;
            reg.RoomId       = resource.RoomId;
            reg.Room         = room;
            reg.CheckInDate  = resource.Start;
            reg.CheckOutDate = resource.End;

            _repository.SaveChanges();

            return(Ok(new RegistrationDTO(reg)));
        }
示例#3
0
        public ActionResult <RegistrationDTO> Add([FromBody] AddRegistrationResource resource)
        {
            var client = _repository.GetOrAddClient(resource.ClientName, resource.Phone);
            var room   = _repository.GetRoom(resource.RoomId);

            var reg = new Registration()
            {
                Id           = new Guid(),
                ClientId     = client.Id,
                Client       = client,
                RoomId       = room.Id,
                Room         = room,
                CheckInDate  = resource.Start,
                CheckOutDate = resource.End
            };

            _repository.AddRegistation(reg);

            return(Ok(new RegistrationDTO(reg)));
        }