Esempio n. 1
0
        public string PostSpace(string value)
        {
            JObject obj = JObject.Parse(value);

            var Id            = obj["Id"];
            var Name          = obj["Name"];
            var Configuration = obj["Configuration"];

            if (Id != null && !string.IsNullOrEmpty(Id.ToString()))
            {
                var space = db.Spaces.Find(Id.ToString());
                if (space == null)
                {
                    logger.Info("NoSpaceFoundInDb - User : "******"NoSpaceFoundInDb" }));
                }

                DesignManager designManager = new DesignManager();
                // Create css file specific for this space with the colour provided by the user async
                designManager.CreateUpdateCssFileForSpace(space.Id, designManager.getColourDesignOfSpace(Configuration.ToString()));

                space.Name          = Name.ToString();
                space.Configuration = Configuration.ToString();
                space.Metadata      = ActivityFactory.SetMetadata(User.Identity.GetUserName(), value, "PostSpace", space.Metadata);

                db.Entry(space).State = EntityState.Modified;
                db.SaveChanges();

                return(JsonConvert.SerializeObject(new { error = false, space = space }));
            }
            else
            {
                var space = new Space();
                space.Name          = Name.ToString();
                space.Configuration = Configuration.ToString();
                space.Metadata      = ActivityFactory.SetMetadata(User.Identity.GetUserName(), value, "PostSpace", space.Metadata);

                db.Spaces.Add(space);
                db.SaveChanges();
                return(JsonConvert.SerializeObject(new { error = false, space = space }));
            }
        }
Esempio n. 2
0
        public string PostSpaceForCurrentUser(string value)
        {
            JObject obj = JObject.Parse(value);

            var Name          = obj["Name"];
            var Configuration = obj["Configuration"];

            ApplicationDbContext         context     = new ApplicationDbContext();
            IUserStore <ApplicationUser> store       = new UserStore <ApplicationUser>(context);
            ApplicationUserManager       UserManager = new ApplicationUserManager(store);
            var claims = UserManager.GetClaims(User.Identity.GetUserId());
            var claim  = claims.Where(a => a.Type == "SpaceId").FirstOrDefault();

            if (claim != null)
            {
                var space = db.Spaces.Find(claim.Value);
                if (space == null)
                {
                    logger.Info("NoSpaceFoundInDb - User : "******"NoSpaceFoundInDb" }));
                }

                DesignManager designManager = new DesignManager();
                // Create css file specific for this space with the colour provided by the user async
                designManager.CreateUpdateCssFileForSpace(space.Id, designManager.getColourDesignOfSpace(Configuration.ToString()));

                space.Name          = Name.ToString();
                space.Configuration = Configuration.ToString();
                space.Metadata      = ActivityFactory.SetMetadata(User.Identity.GetUserName(), value, "PostSpaceForCurrentUser", space.Metadata);

                db.Entry(space).State = EntityState.Modified;
                db.SaveChanges();

                return(JsonConvert.SerializeObject(new { error = false, space = space }));
            }

            logger.Info("NoSpaceFoundInUserConfig - User : "******"NoSpaceFoundInUserConfig" }));
        }