コード例 #1
0
        public ActionResult Create(ReservationInputDto input)
        {
            if (!this.ModelState.IsValid)
            {
                var message = this.ValidateFields();
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest, message));
            }

            try
            {
                var reservation = input;
                this.reservationService.Add(reservation);
                return(new HttpStatusCodeResult(HttpStatusCode.OK));
            }
            catch (Exception e)
            {
                var message = e.Message;
                return(new HttpStatusCodeResult(HttpStatusCode.InternalServerError, message));
            }
        }
コード例 #2
0
        /// <summary>
        /// 編輯模式下初始化界面數據
        /// </summary>
        private void InintData()
        {
            ReservationOutputDto current = this.GetContext <ReservationOutputDto>();

            //不爲null表示處於編輯模式
            if (current != null)
            {
                Dto = new ReservationInputDto
                {
                    DepartmentID    = current.DepartmentID,
                    DepartmentName  = current.DepartmentName,
                    DoctorName      = current.DoctorName,
                    Gender          = current.Gender,
                    Index           = current.Index,
                    BusinessNumber  = current.BusinessNumber,
                    Name            = current.Name,
                    ReservationTime = current.ReservationTime
                };
            }
        }
 public ReservationDto Add(ReservationInputDto input)
 {
     this._repository.Add(Mapper.Map <Reservation>(input));
     this._unitOfWork.SaveChanges();
     return(Mapper.Map <ReservationDto>(input));
 }