Ejemplo n.º 1
0
        public ActionResult Add(AddEditDimensionalModelDataViewModel vModel, HttpPostedFileBase modelFile)
        {
            ApplicationUser authedUser = UserManager.FindById(User.Identity.GetUserId());
            string          message;

            try
            {
                IDimensionalModelData newModel = vModel.DataObject;

                foreach (IDimensionalModelPlane plane in newModel.ModelPlanes)
                {
                    foreach (IDimensionalModelNode node in plane.ModelNodes)
                    {
                        node.YAxis = plane.YAxis;
                    }
                }

                if (newModel.IsModelValid())
                {
                    if (newModel.Create(authedUser.GameAccount, authedUser.GetStaffRank(User)) == null)
                    {
                        message = "Error; Creation failed.";
                    }
                    else
                    {
                        LoggingUtility.LogAdminCommandUsage("*WEB* - AddDimensionalModelData[" + newModel.Id.ToString() + "]", authedUser.GameAccount.GlobalIdentityHandle);
                        message = "Creation Successful.";
                    }
                }
                else
                {
                    message = "Invalid model file; Model files must contain 21 planes of a tag name followed by 21 rows of 21 nodes.";
                }
            }
            catch (Exception ex)
            {
                LoggingUtility.LogError(ex, false);
                message = "Error; Creation failed.";
            }

            return(RedirectToAction("Index", new { Message = message }));
        }