コード例 #1
0
        public JsonResult Manage(HotelRoomTypeModel model, GridManagingModel manageModel)
        {
            if (ModelState.IsValid || manageModel.Operation == GridOperationEnums.Del)
            {
                return Json(_hotelRoomTypeServices.ManageHotelRoomType(manageModel.Operation, model));
            }

            return Json(new ResponseModel
            {
                Success = false,
                Message = GetFirstValidationResults(ModelState).Message
            });
        }
コード例 #2
0
        /// <summary>
        /// Manage user RoomType
        /// </summary>
        /// <param name="operation">the operation</param>
        /// <param name="model">the user RoomType model</param>
        /// <returns></returns>
        public ResponseModel ManageHotelRoomType(GridOperationEnums operation, HotelRoomTypeModel model)
        {
            ResponseModel response;
            Mapper.CreateMap<HotelRoomTypeModel, HotelRoomType>();
            HotelRoomType hotelRoomType;
            switch (operation)
            {
                case GridOperationEnums.Edit:
                    hotelRoomType = _hotelRoomTypeRepository.GetById(model.Id);
                    hotelRoomType.Name = model.Name;
                    hotelRoomType.RecordOrder = model.RecordOrder;
                    hotelRoomType.RecordActive = model.RecordActive;
                    response = Update(hotelRoomType);
                    return response.SetMessage(response.Success ?
                        _localizedResourceServices.T("AdminModule:::HotelRoomTypes:::Messages:::UpdateSuccessfully:::Update HotelRoom type successfully.")
                        : _localizedResourceServices.T("AdminModule:::HotelRoomTypes:::Messages:::UpdateFailure:::Update HotelRoom type failed. Please try again later."));

                case GridOperationEnums.Add:
                    hotelRoomType = Mapper.Map<HotelRoomTypeModel, HotelRoomType>(model);
                    response = Insert(hotelRoomType);
                    return response.SetMessage(response.Success ?
                        _localizedResourceServices.T("AdminModule:::HotelRoomTypes:::Messages:::CreateSuccessfully:::Create HotelRoom type successfully.")
                        : _localizedResourceServices.T("AdminModule:::HotelRoomTypes:::Messages:::CreateFailure:::Create HotelRoom type failed. Please try again later."));

                case GridOperationEnums.Del:
                    response = Delete(model.Id);
                    return response.SetMessage(response.Success ?
                        _localizedResourceServices.T("AdminModule:::HotelRoomTypes:::Messages:::DeleteSuccessfully:::Delete HotelRoom type successfully.")
                        : _localizedResourceServices.T("AdminModule:::HotelRoomTypes:::Messages:::DeleteFailure:::Delete HotelRoom type failed. Please try again later."));
            }
            return new ResponseModel
            {
                Success = false,
                Message = _localizedResourceServices.T("AdminModule:::HotelRoomTypes:::Messages:::ObjectNotFounded:::HotelRoom type is not founded.")
            };
        }