Exemplo n.º 1
0
 public ActionResult DeleteNewsletterReceiver(NewsletterReceiverModel model)
 {
     if (ModelState.IsValid)
     {
         var response = _newsletterReceiverService.Delete(model.Id);
         return new JsonNetResult(new { success = response.IsSucceed, message = response.Message }, JsonRequestBehavior.AllowGet);
     }
     else
         return new JsonNetResult(new { success = false }, JsonRequestBehavior.AllowGet);
 }
Exemplo n.º 2
0
        public ActionResult GetByIdNewsletterReceiver(NewsletterReceiverModel model)
        {
            NewsletterReceiverModel result = null;
            if(ModelState.IsValid)
                result = _newsletterReceiverService.GetById(model.Id);

            if(result != null)
                return new JsonNetResult(new { success = true, data = result }, JsonRequestBehavior.AllowGet);
            else
                return new JsonNetResult(new { success = false }, JsonRequestBehavior.AllowGet);
        }
 public NewsletterReceiverModel GetById(int id)
 {
     NewsletterReceiverModel newsletterReceiverModel = null;
     using (var unitOfWork = _unitOfWorkFactory.Create())
     {
         try
         {
             var entity = unitOfWork.NewsletterReceiverRepository.GetByID(id);
             if (entity != null)
             {
                 newsletterReceiverModel = new NewsletterReceiverModel(entity);
             }
             unitOfWork.Save();
         }
         catch (Exception e)
         {
             _logger.LogToFile(_logger.CreateErrorMessage(e));
         }
     }
     return newsletterReceiverModel;
 }
 public ResponseBase Update(NewsletterReceiverModel newsletterReceiver)
 {
     ResponseBase response;
     using (var unitOfWork = _unitOfWorkFactory.Create())
     {
         try
         {
             if (newsletterReceiver != null)
             {
                 unitOfWork.NewsletterReceiverRepository.Update(newsletterReceiver.ToEntity());
             }
             unitOfWork.Save();
             response = new ResponseBase() { IsSucceed = true, Message = Modules.Resources.Logic.NewsletterReceiverUpdateSuccess };
         }
         catch (Exception e)
         {
             _logger.LogToFile(_logger.CreateErrorMessage(e));
             response = new ResponseBase() { IsSucceed = false, Message = Modules.Resources.Logic.NewsletterReceiverUpdateFailed };
         }
         return response;
     }
 }