Exemplo n.º 1
0
        public IActionResult Api([FromBody] DesignerDto designerDto)
        {
            var allParameters = new NameValueCollection();
            var keys          = designerDto.RequestQueryParameters.ToList();

            foreach (var parameter in keys)
            {
                allParameters.Add(parameter.Key, parameter.Value);
            }

            Stream stream = null;

            if (designerDto.FormStream != null)
            {
                var byteArray = Encoding.ASCII.GetBytes(designerDto.FormStream);
                stream = new MemoryStream(byteArray);
            }

            var result = _workflowService.Designer(allParameters, stream);

            if (allParameters["operation"].Equals("downloadscheme", StringComparison.InvariantCultureIgnoreCase))
            {
                return(File(Encoding.UTF8.GetBytes(result), "text/xml", "scheme.xml"));
            }

            return(Content(result));
        }
        public ActionResult Post(int projectId, [FromBody] DesignerDto model)
        {
            if (!ModelState.IsValid)
            {
                return(Content("ModelState is invalid!"));
            }

            var project = _context.Projects
                          .Include(x => x.Designers)
                          .FirstOrDefault(x => x.Id == projectId);

            if (project == null)
            {
                return(Content("Brak projektu o podanym ID w bazie!"));
            }

            var designer = _mapper.Map <Designer>(model);

            project.Designers.Add(designer);

            _context.SaveChanges();

            return(Ok(project));
        }
Exemplo n.º 3
0
        public ActionResult Create(DesignerDto drod)
        {
            OperationResult oper = _designerContract.Insert(drod);

            return(Json(oper));
        }