Esempio n. 1
0
 public ActionResult Edit(ServiceManageModel model, SubmitTypeEnums submit)
 {
     if (ModelState.IsValid)
     {
         var response = _serviceServices.SaveServiceManageModel(model);
         if (response.Success)
         {
             SetSuccessMessage(response.Message);
             switch (submit)
             {
                 case SubmitTypeEnums.Save:
                     return RedirectToAction("Index");
                 default:
                     return RedirectToAction("Edit", new { id = model.Id });
             }
         }
         SetErrorMessage(response.Message);
     }
     model.StatusList = _serviceServices.GetStatus();
     return View(model);
 }
Esempio n. 2
0
        /// <summary>
        /// Save Service manage model
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public ResponseModel SaveServiceManageModel(ServiceManageModel model)
        {
            ResponseModel response;
            var service = GetById(model.Id);

            #region Edit Service
            if (service != null)
            {
                service.Title = model.Title;

                service.Status = model.Status;
                service.Description = model.Description;
                service.Content = model.Content;
                service.ImageUrl = model.ImageUrl;

                //Get page record order
                response = Update(service);
                return response.SetMessage(response.Success ?
                    _localizedResourceServices.T("AdminModule:::Services:::Messages:::UpdateSuccessfully:::Update service successfully.")
                    : _localizedResourceServices.T("AdminModule:::Services:::Messages:::UpdateFailure:::Update service failed. Please try again later."));
            }
            #endregion

            service = new Service
            {
                Title = model.Title,
                Status = model.Status,
                Description = model.Description,
                Content = model.Content,
                ImageUrl = model.ImageUrl
            };
            response = Insert(service);
            return response.SetMessage(response.Success ?
                _localizedResourceServices.T("AdminModule:::Services:::Messages:::CreateSuccessfully:::Create service successfully.")
                : _localizedResourceServices.T("AdminModule:::Services:::Messages:::CreateFailure:::Create service failed. Please try again later."));
        }