public JsonResult Manage(HotelCustomerModel model, GridManagingModel manageModel)
        {
            if (ModelState.IsValid || manageModel.Operation == GridOperationEnums.Del)
            {
                return Json(_hotelCustomerServices.ManageHotelCustomer(manageModel.Operation, model));
            }

            return Json(new ResponseModel
            {
                Success = false,
                Message = GetFirstValidationResults(ModelState).Message
            });
        }
Exemple #2
0
        /// <summary>
        /// Manage Site HotelCustomer
        /// </summary>
        /// <param name="operation">the operation</param>
        /// <param name="model">the HotelCustomer model</param>
        /// <returns></returns>
        public ResponseModel ManageHotelCustomer(GridOperationEnums operation, HotelCustomerModel model)
        {
            ResponseModel response;
            Mapper.CreateMap<HotelCustomerModel, HotelCustomer>();
            HotelCustomer hotelCustomer;
            switch (operation)
            {
                case GridOperationEnums.Edit:
                    hotelCustomer = GetById(model.Id);
                    hotelCustomer.FullName = model.FullName;
                    hotelCustomer.Email = model.Email;
                    hotelCustomer.IndentityNumber = model.IndentityNumber;
                    hotelCustomer.Address = model.Address;
                    hotelCustomer.Country = model.Country;
                    hotelCustomer.Phone = model.Phone;
                    hotelCustomer.Note = model.Note;

                    response = Update(hotelCustomer);
                    return response.SetMessage(response.Success ?
                        _localizedResourceServices.T("AdminModule:::HotelCustomers:::Messages:::UpdateSuccessfully:::Update customer successfully.")
                        : _localizedResourceServices.T("AdminModule:::HotelCustomers:::Messages:::UpdateFailure:::Update customer failed. Please try again later."));

                case GridOperationEnums.Add:
                    hotelCustomer = Mapper.Map<HotelCustomerModel, HotelCustomer>(model);

                    response = Insert(hotelCustomer);
                    return response.SetMessage(response.Success ?
                        _localizedResourceServices.T("AdminModule:::HotelCustomers:::Messages:::CreateSuccessfully:::Create customer successfully.")
                        : _localizedResourceServices.T("AdminModule:::HotelCustomers:::Messages:::CreateFailure:::Insert customer failed. Please try again later."));

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