Esempio n. 1
0
        public bool SaveBlog(Blog entity)
        {
            if (entity.Id == default)
            {
                _context.Entry(entity).State = EntityState.Added;
            }
            else
            {
                _context.Entry(entity).State = EntityState.Modified;
            }

            _context.SaveChanges();

            return(true);
        }
Esempio n. 2
0
        public bool SaveTrainerCategory(TrainerCategory entity)
        {
            if (!ContainsTrainerCategoryByName(entity.Name))
            {
                if (entity.Id == default)
                {
                    _context.Entry(entity).State = EntityState.Added;
                }
                else
                {
                    _context.Entry(entity).State = EntityState.Modified;
                }

                _context.SaveChanges();

                return(true);
            }

            return(false);
        }
Esempio n. 3
0
        public bool SaveGender(Gender entity)
        {
            if (!ContainsGenderByName(entity.Name))
            {
                if (entity.Id == default)
                {
                    _context.Entry(entity).State = EntityState.Added;
                }
                else
                {
                    _context.Entry(entity).State = EntityState.Modified;
                }

                _context.SaveChanges();

                return(true);
            }

            return(false);
        }
Esempio n. 4
0
        public bool SaveTestimonial(Testimonial entity)
        {
            if (entity.Id == default)
            {
                if (!ContainsTestimonialByClientId(entity.ClientId))
                {
                    _context.Entry(entity).State = EntityState.Added;
                    _context.SaveChanges();

                    return(true);
                }
            }
            else
            {
                var oldVersionEntity = GetTestimonialById(entity.Id);

                if (oldVersionEntity.ClientId != entity.ClientId)
                {
                    if (!ContainsTestimonialByClientId(entity.ClientId))
                    {
                        _context.Entry(entity).State = EntityState.Modified;
                        _context.SaveChanges();

                        return(true);
                    }
                    else
                    {
                        _context.Entry(entity).State = EntityState.Modified;
                        _context.SaveChanges();

                        return(true);
                    }
                }
            }

            return(false);
        }
Esempio n. 5
0
        public bool SaveClient(Client entity)
        {
            if (entity.Id == default)
            {
                if (!ContainsClientByUserId(entity.UserId))
                {
                    _context.Entry(entity).State = EntityState.Added;
                    _context.SaveChanges();

                    return(true);
                }
            }
            else
            {
                var oldVersionEntity = GetClientById(entity.Id);

                if (oldVersionEntity.UserId != entity.UserId)
                {
                    if (!ContainsClientByUserId(entity.UserId))
                    {
                        _context.Entry(entity).State = EntityState.Modified;
                        _context.SaveChanges();

                        return(true);
                    }
                }
                else
                {
                    _context.Entry(entity).State = EntityState.Modified;
                    _context.SaveChanges();

                    return(true);
                }
            }

            return(false);
        }
Esempio n. 6
0
        public bool SaveService(Service entity)
        {
            if (entity.Id == default)
            {
                if (!ContainsServiceByCategoryIdAndName(entity.CategoryId, entity.Name))
                {
                    _context.Entry(entity).State = EntityState.Added;
                    _context.SaveChanges();

                    return(true);
                }
            }
            else
            {
                var oldVersionEntity = GetServiceById(entity.Id);

                if (oldVersionEntity.Name != entity.Name)
                {
                    if (!ContainsServiceByCategoryIdAndName(entity.CategoryId, entity.Name))
                    {
                        _context.Entry(entity).State = EntityState.Modified;
                        _context.SaveChanges();

                        return(true);
                    }
                }
                else
                {
                    _context.Entry(entity).State = EntityState.Modified;
                    _context.SaveChanges();

                    return(true);
                }
            }

            return(false);
        }