예제 #1
0
 public ResponseBase Delete(long id)
 {
     ResponseBase response;
     using (var unitOfWork = _unitOfWorkFactory.Create())
     {
         try
         {
             var button = new MenuButtonModel(unitOfWork.MenuButtonRepository.GetByID(id));
             var children = GetChildButtons(button);
             if (children != null)
             {
                 foreach (var child in children)
                 {
                     unitOfWork.MenuButtonRepository.Delete(child.Id);
                 }
             }
             unitOfWork.Save();
             response = new ResponseBase() { IsSucceed = true, Message = Modules.Resources.Logic.MenuButtonDeleteSuccess };
         }
         catch (Exception e)
         {
             _logger.LogToFile(_logger.CreateErrorMessage(e));
             response = new ResponseBase() { IsSucceed = false, Message = Modules.Resources.Logic.MenuButtonDeleteFailed };
         }
     }
     return response;
 }
예제 #2
0
 public ResponseBase Delete(int id)
 {
     ResponseBase response;
     using (var unitOfWork = _unitOfWorkFactory.Create())
     {
         try
         {
             var fileEntity = unitOfWork.FileRepository.Get(x => x.Id==id).FirstOrDefault();
             if (fileEntity != null)
             {
                 if (!_fileManager.DeleteFile(fileEntity.Path))
                 {
                     return new ResponseBase() { IsSucceed = false, Message = Modules.Resources.Logic.FileDeleteFailed };
                 }
                 unitOfWork.FileRepository.Delete(id);
             }
             unitOfWork.Save();
             response = new ResponseBase() { IsSucceed = true, Message = Modules.Resources.Logic.FileDeleteSuccess };
         }
         catch (Exception e)
         {
             _logger.LogToFile(_logger.CreateErrorMessage(e));
             response = new ResponseBase() { IsSucceed = false, Message = Modules.Resources.Logic.FileDeleteFailed };
         }
     }
     return response;
 }
예제 #3
0
 public ResponseBase Delete(long id)
 {
     ResponseBase response;
     using (var unitOfWork = _unitOfWorkFactory.Create())
     {
         try
         {
             unitOfWork.UserRepository.Delete(id);
             unitOfWork.Save();
             response = new ResponseBase()
             {
                 IsSucceed = true,
                 Message = Modules.Resources.Logic.RemoveUserSuccess
             };
         }
         catch (Exception e)
         {
             _logger.LogToFile(_logger.CreateErrorMessage(e));
             response = new ResponseBase()
             {
                 IsSucceed = false,
                 Message = Modules.Resources.Logic.RemoveUserFailed
             };
         }
     }
     return response;
 }
        public static ResponseBase SendMail(Dictionary<string, string> settingsProperties, string mailAddress, string content, string subject)
        {
            ResponseBase response;
            var client = ConfigureSmtpClient(settingsProperties);
            var message = BuildMailMessage(mailAddress, content, subject, settingsProperties["EmailUsername"]);

            try
            {
                client.Send(message);
                response = new ResponseBase() { IsSucceed = true, Message = Logic.MailSendSuccess };
            }
            catch (Exception e)
            {
                response = new ResponseBase() { IsSucceed = false, Message = Logic.ModifyUserFailed };
                throw new SmtpException();
            }

            return response;
        }
예제 #5
0
 public ResponseBase Delete(int id)
 {
     ResponseBase response;
     using (var unitOfWork = _unitOfWorkFactory.Create())
     {
         try
         {
             if (id > 0)
             {
                 unitOfWork.RegistratedServiceRepository.Delete(id);
             }
             unitOfWork.Save();
             response = new ResponseBase() { IsSucceed = true, Message = Modules.Resources.Logic.ServiceDeleteSuccess };
         }
         catch (Exception e)
         {
             _logger.LogToFile(_logger.CreateErrorMessage(e));
             response = new ResponseBase() { IsSucceed = false, Message = Modules.Resources.Logic.ServiceDeleteFailed };
         }
         return response;
     }
 }
 public ResponseBase Insert(ServiceTypeModel serviceType)
 {
     ResponseBase response;
     using (var unitOfWork = _unitOfWorkFactory.Create())
     {
         try
         {
             if (serviceType != null)
             {
                 unitOfWork.ServiceTypeRepository.Insert(serviceType.ToEntity());
             }
             unitOfWork.Save();
             response = new ResponseBase() { IsSucceed = true, Message = Modules.Resources.Logic.ServiceTypeSaveSuccess };
         }
         catch (Exception e)
         {
             _logger.LogToFile(_logger.CreateErrorMessage(e));
             response = new ResponseBase() { IsSucceed = false, Message = Modules.Resources.Logic.ServiceTypeSaveFailed };
         }
         return response;
     }
 }
예제 #7
0
        public ResponseBase UploadWithInsert(HttpPostedFileBase file, string name)
        {
            ResponseBase response;
            using (var unitOfWork = _unitOfWorkFactory.Create())
            {
                try
                {
                    if (file != null)
                    {
                        var fileData = GetFileData(file);
                        var filePath = GetFilePath(file);
                        if (!_fileManager.SaveFile(filePath, fileData))
                        {
                            return new ResponseBase() { IsSucceed = false, Message = Modules.Resources.Logic.FileUpdateFailed };
                        }
                        FileModel model = new FileModel()
                        {
                            Name = name,
                            Path = filePath,
                            FileType = GetFileType(file),
                            Extension = Path.GetExtension(file.FileName),
                            Size = file.ContentLength

                        };
                        unitOfWork.FileRepository.Insert(model.ToEntity());
                    }

                    unitOfWork.Save();
                    response = new ResponseBase() { IsSucceed = true, Message = Modules.Resources.Logic.FileUpdateSuccess };
                }
                catch (Exception e)
                {
                    _logger.LogToFile(_logger.CreateErrorMessage(e));
                    response = new ResponseBase() { IsSucceed = false, Message = Modules.Resources.Logic.FileUpdateFailed };
                }
            }
            return response;
        }
예제 #8
0
        public ResponseBase Update(FileModel file)
        {
            ResponseBase response;
            using (var unitOfWork = _unitOfWorkFactory.Create())
            {
                try
                {
                    if (file != null)
                        unitOfWork.FileRepository.Update(file.ToEntity());

                    unitOfWork.Save();
                    response = new ResponseBase() { IsSucceed = true, Message = Modules.Resources.Logic.FileUpdateSuccess };
                }
                catch (Exception e)
                {
                    _logger.LogToFile(_logger.CreateErrorMessage(e));
                    response = new ResponseBase() { IsSucceed = false, Message = Modules.Resources.Logic.FileUpdateFailed };
                }
            }
            return response;
        }
예제 #9
0
 public ResponseBase Update(MenuButtonModel menuButton)
 {
     ResponseBase response;
     using (var unitOfWork = _unitOfWorkFactory.Create())
     {
         try
         {
             if (menuButton != null)
             {
                 UpdateButtons(menuButton,unitOfWork);
             }
             unitOfWork.Save();
             response = new ResponseBase() { IsSucceed = true, Message = Modules.Resources.Logic.MenuButtonUpdateSuccess };
         }
         catch (Exception e)
         {
             _logger.LogToFile(_logger.CreateErrorMessage(e));
             response = new ResponseBase() { IsSucceed = false, Message = Modules.Resources.Logic.MenuButtonUpdateFailed };
         }
         return response;
     }
 }
예제 #10
0
 public ResponseBase Update(RegistratedServiceModel model)
 {
     ResponseBase response;
     using (var unitOfWork = _unitOfWorkFactory.Create())
     {
         try
         {
             if (model != null)
             {
                 unitOfWork.RegistratedServiceRepository.Update(model.ToEntity());
             }
             unitOfWork.Save();
             response = new ResponseBase() { IsSucceed = true, Message = Modules.Resources.Logic.ServiceUpdateSuccess };
         }
         catch (Exception e)
         {
             _logger.LogToFile(_logger.CreateErrorMessage(e));
             response = new ResponseBase() { IsSucceed = false, Message = Modules.Resources.Logic.ServiceUpdateFailed };
         }
         return response;
     }
 }
예제 #11
0
        public ResponseBase Update(Dictionary<string, string> settingsDictionary)
        {
            ResponseBase response;
            using (var unitOfWork = _unitOfWorkFactory.Create())
            {
                try
                {
                    foreach (var settingsProperty in settingsDictionary.Keys)
                    {
                        var previousPropertyValue = unitOfWork.SettingsRepository.Get(x => x.Name == settingsProperty).FirstOrDefault();
                        previousPropertyValue.Value = settingsDictionary[settingsProperty];
                        unitOfWork.Save();
                    }

                    response = new ResponseBase() { IsSucceed = true, Message = Modules.Resources.Logic.SettingsUpdateSuccess };
                }
                catch (Exception e)
                {
                    _logger.LogToFile(_logger.CreateErrorMessage(e));
                    response = new ResponseBase() { IsSucceed = false, Message = Modules.Resources.Logic.SettingsUpdateFailed };
                }
            }
            return response;
        }
예제 #12
0
 public ResponseBase Update(UserModel user)
 {
     ResponseBase response;
     using (var unitOfWork = _unitOfWorkFactory.Create())
     {
         try
         {
             if (user != null)
             {
                 unitOfWork.UserRepository.Update(user.ToEntity());
             }
             unitOfWork.Save();
             response = new ResponseBase() { IsSucceed = true, Message = Modules.Resources.Logic.ModifyUserSuccess };
         }
         catch (Exception e)
         {
             _logger.LogToFile(_logger.CreateErrorMessage(e));
             response = new ResponseBase() { IsSucceed = false, Message = Modules.Resources.Logic.ModifyUserFailed };
         }
     }
     return response;
 }
예제 #13
0
        public ResponseBase Update(IList<PopUpModel> popUps)
        {
            ResponseBase response;
            using (var unitOfWork = _unitOfWorkFactory.Create())
            {
                try
                {
                    if (popUps != null)
                    {
                        foreach (var popUp in popUps)
                        {
                            unitOfWork.PopUpRepository.Update(popUp.ToEntity());
                        }

                    }
                    unitOfWork.Save();
                    response = new ResponseBase() { IsSucceed = true, Message = Modules.Resources.Logic.PopUpModifySuccess };
                }
                catch (Exception e)
                {
                    _logger.LogToFile(_logger.CreateErrorMessage(e));
                    response = new ResponseBase() { IsSucceed = false, Message = Modules.Resources.Logic.PopUpModifyFailed };
                }
            }
            return response;
        }
예제 #14
0
 public ResponseBase Insert(PopUpModel popUp)
 {
     ResponseBase response;
     using (var unitOfWork = _unitOfWorkFactory.Create())
     {
         try
         {
             if (popUp != null)
             {
                 unitOfWork.PopUpRepository.Insert(popUp.ToEntity());
             }
             unitOfWork.Save();
             response = new ResponseBase() { IsSucceed = true, Message = Modules.Resources.Logic.PopUpModifySuccess };
         }
         catch (Exception e)
         {
             _logger.LogToFile(_logger.CreateErrorMessage(e));
             response = new ResponseBase() { IsSucceed = false, Message = Modules.Resources.Logic.PopUpInsertFailed };
         }
         return response;
     }
 }
 public ResponseBase Insert(NewsletterReceiverModel newsletterReceiver)
 {
     ResponseBase response;
     using (var unitOfWork = _unitOfWorkFactory.Create())
     {
         try
         {
             if (newsletterReceiver != null)
             {
                 unitOfWork.NewsletterReceiverRepository.Insert(newsletterReceiver.ToEntity());
             }
             unitOfWork.Save();
             response = new ResponseBase() { IsSucceed = true, Message = Modules.Resources.Logic.NewsletterReceiverInsertSuccess };
         }
         catch (Exception e)
         {
             _logger.LogToFile(_logger.CreateErrorMessage(e));
             response = new ResponseBase() { IsSucceed = false, Message = Modules.Resources.Logic.NewsletterReceiverInsertFailed };
         }
         return response;
     }
 }
예제 #16
0
 public ResponseBase Update(ServiceTypeModel serviceType)
 {
     ResponseBase response;
     using (var unitOfWork = _unitOfWorkFactory.Create())
     {
         try
         {
             if (serviceType != null)
             {
                 unitOfWork.ServiceTypeRepository.Update(serviceType.ToEntity());
                 UpdateServicePhases(serviceType.Phases.Where(x => x.ServiceTypeId != 0).ToList(), unitOfWork);
                 AddServicePhases(serviceType.Phases.Where(x=>x.ServiceTypeId==0).ToList(),unitOfWork,serviceType.Id);
                 DeleteServicePhases(serviceType,unitOfWork);
             }
             unitOfWork.Save();
             response = new ResponseBase() { IsSucceed = true, Message = Modules.Resources.Logic.ServiceTypeModifySuccess };
         }
         catch (Exception e)
         {
             _logger.LogToFile(_logger.CreateErrorMessage(e));
             response = new ResponseBase() { IsSucceed = false, Message = Modules.Resources.Logic.ServiceTypeModifyFailed };
         }
     }
     return response;
 }
예제 #17
0
 public ResponseBase Insert(MenuButtonModel menuButton)
 {
     ResponseBase response;
     using (var unitOfWork = _unitOfWorkFactory.Create())
     {
         try
         {
             if (menuButton != null)
             {
                 unitOfWork.MenuButtonRepository.Insert(menuButton.ToEntity());
             }
             unitOfWork.Save();
             response = new ResponseBase() { IsSucceed = true, Message = Modules.Resources.Logic.MenuButtonInsertSuccess };
         }
         catch (Exception e)
         {
             _logger.LogToFile(_logger.CreateErrorMessage(e));
             response = new ResponseBase() { IsSucceed = false, Message = Modules.Resources.Logic.MenuButtonInsertFailed };
         }
         return response;
     }
 }
 public ResponseBase Update(NewsCategoryModel newsCategory)
 {
     ResponseBase response;
     using (var unitOfWork = _unitOfWorkFactory.Create())
     {
         try
         {
             if (newsCategory != null)
             {
                 unitOfWork.NewsCategoryRepository.Update(newsCategory.ToEntity());
             }
             unitOfWork.Save();
             response = new ResponseBase(){IsSucceed = true, Message = Modules.Resources.Logic.NewsCategoryUpdateSuccess };
         }
         catch (Exception e)
         {
             _logger.LogToFile(_logger.CreateErrorMessage(e));
             response = new ResponseBase() { IsSucceed = false, Message = Modules.Resources.Logic.NewsCategoryUpdateFailed };
         }
         return response;
     }
 }