private void AddImportedData(ImportedFormatModel importedFormat)
        {
            try
            {
                formatService.Add(importedFormat.ImportedFormat);

                foreach (StyleClass styleClass in importedFormat.ImportedStyleClasses)
                {
                    try
                    {
                        styleClassService.Add(styleClass);
                    }
                    catch (ExistingStyleClassException exception)
                    {
                        MessageBox.Show(exception.Message);
                    }
                }

                foreach (Style style in importedFormat.ImportedStyles)
                {
                    try
                    {
                        styleService.Add(style.Format.Name, style.StyleClass.Name, style);
                    }
                    catch (InvalidStyleException exception)
                    {
                        MessageBox.Show(exception.Message);
                    }
                }
            }
            catch (ExistingFormatException exception)
            {
                MessageBox.Show(exception.Message);
            }
        }
Example #2
0
 private void btnAddFormat_Click(object sender, EventArgs e)
 {
     if (tbxFormatName.Text != "")
     {
         Format newFormat = new Format()
         {
             Name = tbxFormatName.Text
         };
         try
         {
             formatManager.Add(newFormat);
             MessageBox.Show("The Format was added successfully.");
             this.Close();
         }
         catch (ExistingFormatException exception)
         {
             MessageBox.Show(exception.Message);
         }
     }
 }
Example #3
0
        public IHttpActionResult Add([FromBody] AddFormat format)
        {
            if (IsTokenValid() && authenticationService.IsAllowedToAddFormats(GetTokenUserEmail()))
            {
                try
                {
                    Format     newStyleClass  = formatManagementService.Add(AddFormat.ToEntity(format));
                    BaseFormat modelNewFormat = BaseFormat.ToModel(newStyleClass);

                    return(CreatedAtRoute("AddFormat", new { formatname = modelNewFormat.Name }, modelNewFormat));
                }
                catch (MissingFormatException e)
                {
                    return(BadRequest(e.Message));
                }
                catch (Exceptions e)
                {
                    return(BadRequest(e.Message));
                }
            }

            return(Unauthorized());
        }