Exemple #1
0
        public ActionResult Edit(ProjectCategoryOrganizationSettings projectCategoryOrganizationSettings, bool EnableProjectCategory)
        {
            string email    = Request.Headers["Email"];
            var    tenantId = catalog.GetTenantIDFromClientURL(email);

            try
            {
                if (tenantId == null)
                {
                    return(Json(new
                    {
                        success = false,
                        message = "TenantId is null",
                        data = new { }
                    }, JsonRequestBehavior.AllowGet));
                }
                DateTime dt = DateTime.Now;
                var      currentProjectCategoryID = db.ProjectCategoryOrganizationSettings.FirstOrDefault(p => p.ProjectCategoryID == projectCategoryOrganizationSettings.ProjectCategoryID);

                if (currentProjectCategoryID == null)
                {
                    LogHelper.Log(Log.Event.UPDATE_PROJECTCATEGORY, "ProjectCategoryID not found");
                    return(Json(new
                    {
                        success = false,
                        message = "ProjectCategoryID not found",
                        data = new { }
                    }, JsonRequestBehavior.AllowGet));
                }

                currentProjectCategoryID.EnableProjectCategory = EnableProjectCategory;
                currentProjectCategoryID.DateModified          = dt;

                db.SaveChanges();
            }
            catch (Exception ex)
            {
                LogHelper.Log(Log.Event.UPDATE_PROJECTCATEGORY, ex.Message);
                ExceptionError(ex.Message, ex.StackTrace);
            }
            return(Json(new
            {
                success = true,
                message = "Edited successfully",
                data = db.ProjectCategoryOrganizationSettings.Where(x => x.TenantID == tenantId).Select(x => new
                {
                    x.ProjectCategoryID,
                    x.ProjectCategory.Name,
                    x.EnableProjectCategory
                })
            }, JsonRequestBehavior.AllowGet));
        }
Exemple #2
0
        public void SaveDefaultProjectCategoryRecord(Guid TenantID, Guid OrganizationID)
        {
            DateTime dt = DateTime.Now;
            var      ProjectCategory = db.ProjectCategory.ToList();

            foreach (ProjectCategory source in ProjectCategory)
            {
                db.ProjectCategoryOrganizationSettings.Add(new ProjectCategoryOrganizationSettings()
                {
                    ProjectCategoryID     = source.ProjectCategoryID,
                    OrganizationID        = OrganizationID,
                    TenantID              = TenantID,
                    EnableProjectCategory = false,
                    DateCreated           = dt
                });
                db.SaveChanges();
            }
            var DefaultProjectCategory1   = "Goods";
            var DefaultProjectCategoryID1 = db.ProjectCategory.Where(x => x.Name.Contains(DefaultProjectCategory1)).Select(x => x.ProjectCategoryID).FirstOrDefault();
            var ProjectCategory1          = db.ProjectCategoryOrganizationSettings.Where(x => x.ProjectCategoryID == DefaultProjectCategoryID1 && x.OrganizationID == OrganizationID && x.TenantID == TenantID).ToList();
            ProjectCategoryOrganizationSettings projectCategoryOrganizationSettings = ProjectCategory1.First();

            projectCategoryOrganizationSettings.EnableProjectCategory = true;
            projectCategoryOrganizationSettings.DateModified          = dt;

            var DefaultProjectCategory2   = "Services";
            var DefaultProjectCategoryID2 = db.ProjectCategory.Where(x => x.Name.Contains(DefaultProjectCategory2)).Select(x => x.ProjectCategoryID).FirstOrDefault();
            var ProjectCategory2          = db.ProjectCategoryOrganizationSettings.Where(x => x.ProjectCategoryID == DefaultProjectCategoryID2 && x.OrganizationID == OrganizationID && x.TenantID == TenantID).ToList();

            projectCategoryOrganizationSettings = ProjectCategory2.First();
            projectCategoryOrganizationSettings.EnableProjectCategory = true;
            projectCategoryOrganizationSettings.DateModified          = dt;

            var DefaultProjectCategory3   = "Works";
            var DefaultProjectCategoryID3 = db.ProjectCategory.Where(x => x.Name.Contains(DefaultProjectCategory3)).Select(x => x.ProjectCategoryID).FirstOrDefault();
            var ProjectCategory3          = db.ProjectCategoryOrganizationSettings.Where(x => x.ProjectCategoryID == DefaultProjectCategoryID3 && x.OrganizationID == OrganizationID && x.TenantID == TenantID).ToList();

            projectCategoryOrganizationSettings = ProjectCategory3.First();
            projectCategoryOrganizationSettings.EnableProjectCategory = true;
            projectCategoryOrganizationSettings.DateModified          = dt;

            db.SaveChanges();
        }