Пример #1
0
        public IResult Delete(Univercity entity)
        {
            IUnivercityImageDal univercityImageDal = new EfUnivercityImageDal();
            var result = univercityImageDal.checkIfImageExist(entity.Id);

            if (result)
            {
                var image = univercityImageDal.Get(u => u.UnivercityId == entity.Id);
                univercityImageDal.Delete(image);
            }
            _univercityDal.Delete(entity);
            return(new SuccessResult(Messages.UnivercityDeleted));
        }
Пример #2
0
        public IResult Add(Univercity entity)
        {
            _univercityDal.Add(entity);
            IUnivercityImageDal univercityImageDal = new EfUnivercityImageDal();
            var result = univercityImageDal.checkIfImageExist(entity.Id);

            if (!result)
            {
                UnivercityImage newUniImage = new UnivercityImage
                {
                    UnivercityId = entity.Id,
                    ImagePath    = "default.jpg"
                };
                univercityImageDal.Add(newUniImage);
            }
            return(new SuccessResult(Messages.Univercityadded));
        }