public void delete(long faculty_id)
        {
            try
            {
                using (TransactionScope tx = new TransactionScope(TransactionScopeOption.Required))
                {
                    var FacultyCategory = _facultyRepository.getById(faculty_id);
                    if (FacultyCategory == null)
                    {
                        throw new ItemNotFoundException($"faculty Category With Id {FacultyCategory} doesnot Exist.");
                    }

                    _facultyRepository.delete(FacultyCategory);
                    tx.Complete();
                }
            }

            catch (Exception)
            {
                throw;
            }
        }
Ejemplo n.º 2
0
        public void save(CoursesDto product_dto)
        {
            try
            {
                _transactionManager.beginTransaction();

                Courses product = new Courses();
                _productMaker.copy(ref product, product_dto);
                if (product.faculty_id != 0)
                {
                    product.faculty = _facultyRepository.getById(product.faculty_id) ?? throw new ItemNotFoundException($"Faculty with the id {product.faculty_id} doesnot exist.");
                }

                _productRepo.insert(product);

                _transactionManager.commitTransaction();
            }
            catch (Exception)
            {
                _transactionManager.rollbackTransaction();
                throw;
            }
        }
Ejemplo n.º 3
0
        public IActionResult edit(long faculty_id)
        {
            try
            {
                var        faculty = _facultyRepository.getById(faculty_id);
                FacultyDto dto     = _mapper.Map <FacultyDto>(faculty);

                // RouteData.Values.Remove("faculty_id");
                return(View(dto));
            }
            catch (Exception ex)
            {
                AlertHelper.setMessage(this, ex.Message, messageType.error);
                return(RedirectToAction("index"));
            }
        }