示例#1
0
        public ActionResult Edit(SymbolFile symbolFile, HttpPostedFileBase[] uploadFile, string FileToRemove)
        {
            ViewBag.Size           = new SelectList(CodeList.Size, "Key", "Value");
            ViewBag.SymbolGraphics = new SelectList(CodeList.SymbolGraphics, "Key", "Value");

            var variants = _symbolService.GetSymbolVariant(symbolFile.SymbolFileVariant.SystemId);

            if (!_authorizationService.HasAccess(variants[0].Symbol.Owner,
                                                 ClaimsPrincipal.Current.GetOrganizationName()))
            {
                return(new HttpStatusCodeResult(HttpStatusCode.Unauthorized));
            }

            foreach (var variant in variants)
            {
                variant.SymbolFileVariant.Name = symbolFile.SymbolFileVariant.Name;
                _symbolService.UpdateSymbolFile(variant);
            }

            if (uploadFile != null && uploadFile[0] != null)
            {
                var file = variants.FirstOrDefault();
                symbolFile.SymbolFileVariant = file.SymbolFileVariant;
                symbolFile.Type   = symbolFile.Type;
                symbolFile.Color  = symbolFile.Color;
                symbolFile.Size   = symbolFile.Size;
                symbolFile.Symbol = file.Symbol;
                _symbolService.AddSymbolFiles(symbolFile, uploadFile);
            }

            if (!string.IsNullOrEmpty(FileToRemove))
            {
                var fileToRemove = _symbolService.GetSymbolFile(Guid.Parse(FileToRemove));
                _symbolService.RemoveSymbolFile(fileToRemove);
            }

            variants = _symbolService.GetSymbolVariant(symbolFile.SymbolFileVariant.SystemId);

            return(View(variants));
        }