public IActionResult AddNewMaterial()
        {
            var file          = Request.Form.Files[0];
            var detailsDecode = JObject.Parse(Request.Form["materialDetails"]);

            var folderName = Path.Combine("Resources", "Materials");
            var pathToSave = Path.Combine(Directory.GetCurrentDirectory(), folderName);
            var fullPath   = Path.Combine(pathToSave, file.FileName);

            if (file.Length > 0)
            {
                var dbPath = Path.Combine(folderName, file.FileName);

                using (var stream = System.IO.File.Create(fullPath))
                {
                    file.CopyTo(stream);
                }

                string materialName                = detailsDecode["name"].ToString();
                string materialInformations        = detailsDecode["informations"].ToString();
                string materialChemicalComposition = detailsDecode["chemicalComposition"].ToString();

                var material = new CreateMaterialRequest {
                    Name                   = materialName,
                    MaterialPhoto          = dbPath,
                    AdditionalInformations = materialInformations,
                    ChemicalComposition    = materialChemicalComposition
                };
                materialRepository.Create(material.returnMaterial());
            }
            return(Ok(new ApiResponse("Added succesfully!")));
        }
        public void Add(MaterialData materialData)
        {
            _unitOfWork.BeginTransaction();

            _materialRepository.Create(materialData);

            _unitOfWork.Commit();
        }
 public IActionResult Create([Bind("Id,Title,Amount,MeasureUnitId")] Material material)
 {
     if (materialsRepository.Exists(material))
     {
         ModelState.AddModelError(string.Empty, "Item already exists");
     }
     if (ModelState.IsValid)
     {
         materialsRepository.Create(material);
         return(RedirectToAction("Index"));
     }
     ViewData["MeasureUnitId"] = new SelectList(measureUnitRepository.GetAll(), "Id", "Title", material.MeasureUnitId);
     return(View(material));
 }
Beispiel #4
0
        public async Task <IActionResult> CreateMaterial([FromBody] MaterialDTO materialdto)
        {
            if (string.IsNullOrEmpty(materialdto.Nome))
            {
                return(BadRequest());
            }
            if (await _repository.Exists(materialdto.Nome))
            {
                return(BadRequest());
            }

            Material material = new Material(materialdto);
            await _repository.Create(material);

            MaterialDTO dto = _mapper.Map <Material, MaterialDTO>(material);

            return(Created("Created Material", dto));
        }
Beispiel #5
0
        public MaterialModel Post(MaterialModel material)
        {
            try
            {
                var where = $"PESSOA_ID = {material.FABRICANTE.PESSOA_ID}";
                if (string.IsNullOrEmpty(MetodosGenericosService.DlookupOrcamentaria("PESSOA_ID", "T_ORCA_PESSOA", where)))
                {
                    throw new Exception();
                }

                material.FABRICANTE = PessoaService.GetComParametro(new PessoaQO(material.FABRICANTE.PESSOA_ID, "")).ToArray()[0];

                return(MaterialRepository.Create(material));
            }
            catch (Exception)
            {
                throw;
            }
        }
Beispiel #6
0
 public async Task <Material> Create(Material obj)
 {
     return(await _repository.Create(obj));
 }
 private Material CreateMaterial(Material material)
 {
     return(materialRepository.Create(material));;
 }
 public Material Create(Material material)
 {
     return(materialRepository.Create(material));
 }
Beispiel #9
0
 public void Create(string name, decimal cost)
 {
     _materialRepository.Create(name, cost);
 }
        public IActionResult Criar([FromBody] Material material)
        {
            _repository.Create(material);

            return(Created("Criado com sucesso", material));
        }