Exemplo n.º 1
0
 public ActionResponse AddHelpForProjectLocation(ProjectLocationHelp model)
 {
     using (var unitWork = new UnitOfWork(context))
     {
         ActionResponse response = new ActionResponse();
         try
         {
             var projectHelp = unitWork.HelpRepository.GetOne(h => h.Entity == HelpForEntity.ProjectLocations);
             if (projectHelp != null)
             {
                 projectHelp.HelpInfoJson = JsonConvert.SerializeObject(model);
             }
             else
             {
                 unitWork.HelpRepository.Insert(new EFHelp()
                 {
                     Entity       = HelpForEntity.ProjectLocations,
                     HelpInfoJson = JsonConvert.SerializeObject(model)
                 });
             }
             unitWork.Save();
         }
         catch (Exception ex)
         {
             response.Success = false;
             response.Message = ex.Message;
         }
         return(response);
     }
 }
Exemplo n.º 2
0
        public IActionResult AddProjectLocationHelp([FromBody] ProjectLocationHelp model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            var response = service.AddHelpForProjectLocation(model);

            if (!response.Success)
            {
                return(BadRequest(response.Message));
            }
            return(Ok(true));
        }
Exemplo n.º 3
0
 public ProjectLocationHelp GetHelpForProjectLocationFields()
 {
     using (var unitWork = new UnitOfWork(context))
     {
         ProjectLocationHelp help = new ProjectLocationHelp();
         var projectHelp          = unitWork.HelpRepository.GetOne(h => h.Entity == HelpForEntity.ProjectLocations);
         if (projectHelp != null)
         {
             if (!string.IsNullOrEmpty(projectHelp.HelpInfoJson))
             {
                 help = JsonConvert.DeserializeObject <ProjectLocationHelp>(projectHelp.HelpInfoJson);
             }
         }
         return(help);
     }
 }