示例#1
0
        public ActionResult EditProject(ProjectModel model)
        {
            bool success = false;
            int  id      = 0;

            ProjectBE project = FormLogic.FetchProject(model.ID);

            if (Functions.IsNull(project))
            {
                project = new ProjectBE();
                BusinessEntityHelper.ConvertBEToBEForUI <ProjectModel, ProjectBE>(model, project);
                project.CreatedDateTime     = DateTime.Now;
                project.LastUpdatedDateTime = DateTime.Now;
                project.CreatedBy           = "Habitat";
                project.UpdatedBy           = "Habitat";
                project.ID       = project.ID < 0 ? 0 : project.ID;
                project.ClientID = project.ClientID < 0 ? 0 : project.ClientID;
                success          = FormLogic.AddProject(project, out id);
            }
            else
            {
                project.Project             = model.Project;
                project.ProjectName         = model.ProjectName;
                project.Description         = model.Description;
                project.Manager             = model.Manager;
                project.SiteAddress         = model.SiteAddress;
                project.SitePostcode        = model.SitePostcode;
                project.ClientID            = model.ClientID;
                project.LastUpdatedDateTime = DateTime.Now;
                project.ClientID            = project.ClientID < 0 ? 0 : project.ClientID;
                project.UpdatedBy           = "Habitat";
                success = FormLogic.UpdateProject(project);
            }


            if (success)
            {
                int projectID = model.ID > 0 ? model.ID : id;
                success = FormLogic.SaveProjectForm(projectID, model.ProjectFormList != null ? string.Join(',', model.ProjectFormList) : string.Empty);
            }

            return(Json(new { success, id }));
        }