public bool Add(FreelancerVm entity)
        {
            try
            {
                UpdateByFreelancerUserVm user = new UpdateByFreelancerUserVm
                {
                    Id          = entity.ApplicationUserId,
                    PhoneNumber = entity.PhoneNumber,
                    Avatar      = entity.Avatar,
                    Address     = entity.Address
                };
                _accountService.UpdateByFreelancer(user);

                //preparamos el model del freelancer
                var freelancer = new Freelancer {
                    CreatedAt         = _dateTime,
                    ApplicationUserId = entity.ApplicationUserId,
                    Biography         = entity.Biography,
                    Historial         = entity.Address,
                    Interest          = entity.Interest,
                    Lenguaje          = entity.Lenguaje,
                    Level             = entity.Level,
                    PriceHour         = entity.PriceHour,
                    Rating            = entity.Rating,
                    Lat       = entity.Lat,
                    Long      = entity.Long,
                    Profesion = entity.Profesion
                };

                //agregamos el freelancer
                _dbContext.Add(freelancer);
                _dbContext.SaveChanges();


                FreelancerHability model;
                //buscamos el ultimo id del freelancer
                //e iteramos en el listado de habilidades y los vamos agregando a la tabla
                var id = _dbContext.Freelancers.Max(x => x.Id);
                foreach (var i in entity.Habilities)
                {
                    model = new FreelancerHability
                    {
                        FreelancerId = id,
                        HabilityId   = i.Id
                    };
                    _freelancerHabilityService.Add(model);
                }
                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
 public bool Add(FreelancerHability model)
 {
     try
     {
         _dbContext.FreelancerHabilities.Add(model);
         _dbContext.SaveChanges();
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
        public bool Update(FreelancerVm entity)
        {
            try
            {
                var freelancer = _dbContext.Freelancers.
                                 First(x => x.Id == entity.Id);
                var user = _dbContext.ApplicationUsers.First(x => x.Id == freelancer.ApplicationUserId);

                //ApplicationUser
                user.Name        = entity.Name;
                user.PhoneNumber = entity.PhoneNumber;
                user.LastName    = entity.LastName;

                _dbContext.ApplicationUsers.Update(user);
                //freelancer
                freelancer.Lenguaje  = entity.Lenguaje;
                freelancer.Biography = entity.Biography;
                freelancer.PriceHour = entity.PriceHour;
                freelancer.Interest  = entity.Interest;
                freelancer.ApplicationUser.Address = entity.Address;
                freelancer.Profesion = entity.Profesion;
                freelancer.UpdateAt  = _dateTime;
                freelancer.Long      = entity.Long;
                freelancer.Lat       = entity.Lat;
                _dbContext.Update(freelancer);
                _dbContext.SaveChanges();

                FreelancerHability freelancerHability;
                foreach (var i in entity.Habilities)
                {
                    //si existe no la agreges si no agregala
                    if (!_freelancerHabilityService.Exist(entity.Id, i.Id))
                    {
                        freelancerHability = new FreelancerHability
                        {
                            FreelancerId = entity.Id,
                            HabilityId   = i.Id
                        };
                        _freelancerHabilityService.Add(freelancerHability);
                    }
                }


                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
        public bool Update(FreelancerHability entity)
        {
            try
            {
                var model = _dbContext.FreelancerHabilities.First(x => x.FreelancerId == entity.FreelancerId);
                model.HabilityId = entity.HabilityId;
                _dbContext.Update(model);
                _dbContext.SaveChanges();

                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }