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();
        }
Beispiel #3
0
        public ActionResult Delete(int Id)
        {
            Material deleteMaterial = _materialRepository.DeleteMaterial(Id);

            if (deleteMaterial != null)
            {
                return(RedirectToAction("List"));
            }
            return(RedirectToAction("List"));
        }
        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();
            }
        }
Beispiel #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());
        }
Beispiel #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));
        }
Beispiel #8
0
 public bool DeleteMaterial(int materialId)
 {
     return(repository.DeleteMaterial(materialId));
 }
 public ActionResult Delete(Materials material)
 {
     repositoryM.DeleteMaterial(material);
     return(RedirectToAction("Index"));
 }