public IActionResult Delete(int id)
        {
            materialRepository.DeleteMaterial(id);
            materialRepository.Save();

            return(RedirectToAction("Index"));
        }
        public void DeleteMaterial(int id)
        {
            m_materialRepository.DeleteMaterial(id);

            m_cache.Remove(GetMappablesCacheKey());
            m_materialRepository.CleanCache();
            m_virtualProductRepository.CleanCache();
        }
示例#3
0
        public ActionResult Delete(int Id)
        {
            Material deleteMaterial = _materialRepository.DeleteMaterial(Id);

            if (deleteMaterial != null)
            {
                return(RedirectToAction("List"));
            }
            return(RedirectToAction("List"));
        }
示例#4
0
        public void DeleteMaterial(int materialId)
        {
            //
            var allToys = _toyRepository.GetAll();

            var toysThatUsing = allToys.Where(t => t.MaterialInToy.Select(m => m.UsedMaterial.MaterialId == materialId).Any());

            if (toysThatUsing.Any())
            {
                // hande cant delete
                throw new ObjectUsedException("Материал где-то используется");
            }
            else
            {
                _materialRepository.DeleteMaterial(materialId);
                _materialRepository.Save();
            }
        }
示例#5
0
        public async Task <IActionResult> DeleteMaterial([FromRoute] int id)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var material = repmaterial.GetMaterialByID(id);

            if (material == null)
            {
                return(NotFound());
            }

            repmaterial.DeleteMaterial(id);
            repmaterial.Save();

            return(Ok(material));
        }
        public ActionResult DeleteMaterialForPerson(Guid personId, Guid materialId)
        {
            if (!_materialRepository.PersonExists(personId))
            {
                return(NotFound());
            }

            var materialFromRepo = _materialRepository.GetMaterial(personId, materialId);

            if (materialFromRepo == null)
            {
                return(NotFound());
            }

            _materialRepository.DeleteMaterial(materialFromRepo);
            _materialRepository.Save();

            return(NoContent());
        }
示例#7
0
        /// <summary>
        /// <see cref="IMaterialRepository.DeleteMaterial(Guid)"/>
        /// </summary>
        public bool DeleteMaterial(Guid id, out string errorMessage)
        {
            errorMessage = string.Empty;

            if (id == Guid.Empty)
            {
                errorMessage = "Material id can`t be empty";
                return(false);
            }

            Material materialFromRepository = _rMaterialRepository.GetMaterialById(id);

            if (materialFromRepository == null)
            {
                errorMessage = "Material don`t exist";
                return(false);
            }

            return(_rMaterialRepository.DeleteMaterial(id));
        }
示例#8
0
 public bool DeleteMaterial(int materialId)
 {
     return(repository.DeleteMaterial(materialId));
 }
示例#9
0
 public ActionResult Delete(Materials material)
 {
     repositoryM.DeleteMaterial(material);
     return(RedirectToAction("Index"));
 }