Beispiel #1
0
        public ActionResult Create(SchemaModel model)
        {
            // Check whether file present
            if (model.UploadFile == null)
            {
                Toastr.Error("You should upload a schema");
                return(View(model));
            }

            // Setup stream
            var stream = new MemoryStream();

            model.UploadFile.InputStream.CopyTo(stream);

            // Setup model
            var newSchema = new DataLinker.Models.SchemaModel
            {
                Description    = model.Description,
                PublicId       = model.PublicId,
                IsAggregate    = model.IsAggregate,
                IsIndustryGood = model.IsIndustryGood,
                Name           = model.Name,
                Status         = TemplateStatus.Draft,
                Version        = 1
            };

            // Create new schema
            _dataSchemaService.Create(newSchema, stream.ToArray(), model.UploadFile.FileName, LoggedInUser);

            // Setup status message
            Toastr.Success("Schema was successfully created");

            // Return result
            return(RedirectToAction("Index"));
        }
Beispiel #2
0
        public ActionResult Edit(int id, SchemaModel model)
        {
            MemoryStream stream   = null;
            var          fileName = string.Empty;

            // Check whether file needs to be updated
            if (model.UploadFile != null)
            {
                // Setup file stream
                stream   = new MemoryStream();
                fileName = model.UploadFile.FileName;
                model.UploadFile.InputStream.CopyTo(stream);
            }

            // Setup internal model
            var data = new DataLinker.Models.SchemaModel
            {
                DataSchemaID   = id,
                Description    = model.Description,
                IsAggregate    = model.IsAggregate,
                IsIndustryGood = model.IsIndustryGood,
                Name           = model.Name,
                PublicId       = model.PublicId
            };

            // Update schema
            _dataSchemaService.Update(data, stream, fileName, LoggedInUser);

            // Setup status message
            Toastr.Success("Schema was successfully updated");

            // Return result
            return(RedirectToAction("Index"));
        }