Ejemplo n.º 1
0
        public async Task <UserDTO> Register(NewUserDTO creatingUser)
        {
            var userSNEntity = new UserSocialNetwork()
            {
                UId              = creatingUser.UId,
                ProviderName     = creatingUser.ProviderName,
                SocialNetworkUrl = creatingUser.ProviderUrl,
            };

            var user = _mapper.Map <User>(creatingUser, opt => opt.AfterMap((src, dst) =>
            {
                dst.CreatedAt          = DateTime.Now;
                dst.UserSocialNetworks = new List <UserSocialNetwork> {
                    userSNEntity
                };
            }));

            _context.Add(user);
            await _context.SaveChangesAsync();

            var emailModel = _emailBuilder.GetSignUpLetter(creatingUser.Email, creatingUser.FirstName);
            await _emailService.SendEmailAsync(new List <string> {
                emailModel.Email
            }, emailModel.Subject, emailModel.Title, emailModel.Body);

            return(_mapper.Map <UserDTO>(user));
        }
        //
        // GET: /UserSocialNetworks/Edit/5

        public ActionResult Edit(int id)
        {
            UserSocialNetwork usersocialnetwork = context.UserSocialNetworks.Single(x => x.ID == id);

            ViewBag.PossibleSocialNetworks = context.SocialNetworks;
            return(View(usersocialnetwork));
        }
        public ActionResult DeleteConfirmed(int id)
        {
            UserSocialNetwork usersocialnetwork = context.UserSocialNetworks.Single(x => x.ID == id);

            context.UserSocialNetworks.Remove(usersocialnetwork);
            context.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public ActionResult Edit(UserSocialNetwork usersocialnetwork)
 {
     if (ModelState.IsValid)
     {
         context.Entry(usersocialnetwork).State = EntityState.Modified;
         context.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.PossibleSocialNetworks = context.SocialNetworks;
     return(View(usersocialnetwork));
 }
        public ActionResult Create(UserSocialNetwork usersocialnetwork)
        {
            if (ModelState.IsValid)
            {
                context.UserSocialNetworks.Add(usersocialnetwork);
                context.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.PossibleSocialNetworks = context.SocialNetworks;
            return(View(usersocialnetwork));
        }
Ejemplo n.º 6
0
        public int SaveCredentials(CredentialsViewModel model, string userId)
        {
            var user = UserRepository.Find(u => u.Id == userId);
            var sn   = SocialNetworkRepository.Find(s => s.Id == model.SocialNetworkId);
            var usn  = UserSocialNetworkRepository.Find(r => r.User.Id == userId && r.SocialNetwork.Id == model.SocialNetworkId);

            if (user != null && sn != null)
            {
                var cred = new UserCredentials();
                cred.Login    = CryptoService.GetEncryptedValue(user.PasswordHash, model.Login);
                cred.Password = CryptoService.GetEncryptedValue(user.PasswordHash, model.Password);
                cred.Status   = Domain.Entities.StatusEnums.EntityStatus.Active;

                if (usn != null)
                {
                    if (usn.Credentials != null)
                    {
                        usn.Credentials.Login    = cred.Login;
                        usn.Credentials.Password = cred.Password;
                    }
                    else
                    {
                        usn.Credentials = cred;
                    }
                    UserSocialNetworkRepository.Update(usn);
                }
                else
                {
                    var userSN = new UserSocialNetwork();
                    userSN.SocialNetwork = sn;
                    userSN.User          = user;
                    userSN.Credentials   = cred;
                    UserSocialNetworkRepository.Insert(userSN);
                }
            }
            else
            {
                throw new Exception("User or social network was not found");
            }

            return(1);
        }
Ejemplo n.º 7
0
        public ActionResult GetResumeAsMarkup(int id)
        {
            //var xml = GlobalConfiguration.Configuration.Formatters.XmlFormatter;
            //var dcs = new DataContractSerializer(typeof(Resume), null, int.MaxValue,
            //    false, /* preserveObjectReferences: */ true, null);
            repository._context.Configuration.ProxyCreationEnabled = false;
            var item = repository._context.Resumes
                       .Include(x => x.UserProfile)
                       .Include(x => x.UserProfile.Country)
                       .Include(x => x.ResumeAchievements)
                       .Include(x => x.ResumeEducations)
                       .Include(x => x.ResumeSkills)
                       .Include(x => x.ResumeSocialNetworks)
                       .Include(x => x.ResumeVolunteerExperiences)
                       .AsNoTracking()
                       .FirstOrDefault(x => x.ID == id); //repository.Resume_Get(id);

            foreach (ResumeAchievement x in item.ResumeAchievements)
            {
                Achievement aTmp = repository.Achievement_Get(x.AchievementID);

                item.Achievements.Add(aTmp);
            }

            foreach (ResumeSkill x in item.ResumeSkills)
            {
                Skill aTmp = repository.Skills_Get(x.SkillID);

                item.Skills.Add(aTmp);
            }

            item.Companies = (from company in item.Skills
                              group company by new { company.Company.ID,
                                                     company.Company.Name,
                                                     company.Company.JobTitle,
                                                     company.Company.DateStart,
                                                     company.Company.DateEnd,
                                                     company.Company.URL,
                                                     company.Company.Summary }
                              into gCompanies
                              select new Company
            {
                ID = gCompanies.Key.ID,
                Name = gCompanies.Key.Name,
                JobTitle = gCompanies.Key.JobTitle,
                DateStart = gCompanies.Key.DateStart,
                DateEnd = gCompanies.Key.DateEnd,
                Summary = gCompanies.Key.Summary,
                URL = gCompanies.Key.URL,
                Skills = item.Skills.Where(x => x.Company.ID == gCompanies.Key.ID).ToList()
            }).ToList();

            foreach (ResumeEducation x in item.ResumeEducations)
            {
                Education aTmp = repository.Educations_Get(x.EducationID);

                item.Educations.Add(aTmp);
            }

            foreach (ResumeVolunteerExperience x in item.ResumeVolunteerExperiences)
            {
                VolunteerExperience aTmp = repository.VolunteerExperience_Get(x.VolunteerExperienceID);

                item.VolunteerExperiences.Add(aTmp);
            }

            foreach (ResumeSocialNetwork x in item.ResumeSocialNetworks)
            {
                UserSocialNetwork aTmp = repository.UserSocialNetwork_Get(x.UserSocialNetworkID);

                item.UserSocialNetworks.Add(aTmp);
            }

            //var serializer = new DataContractSerializer(typeof(Resume));
            //var obj = item;
            //StringBuilder sb = new StringBuilder();
            //using (XmlWriter xw = XmlWriter.Create(sb) /*String.Format("{0}\\test.xml", Server.MapPath("/Content")))*/)
            //{
            //    serializer.WriteObject(xw, obj);
            //    xw.Close();
            //}

            using (System.IO.StreamWriter fs = new System.IO.StreamWriter(String.Format("{0}\\test.xml", Server.MapPath("/Content"))))
            {
                fs.Write(item.ToXMLString());
                fs.Close();
            }

            using (System.IO.StreamWriter fs = new System.IO.StreamWriter(String.Format("{0}\\test.html", Server.MapPath("/Content"))))
            {
                fs.Write(item.ToHTMLString(Server.MapPath("~/Content/Resume.xslt")));
                fs.Close();
            }

            return(View());
        }
        //
        // GET: /UserSocialNetworks/Delete/5

        public ActionResult Delete(int id)
        {
            UserSocialNetwork usersocialnetwork = context.UserSocialNetworks.Single(x => x.ID == id);

            return(View(usersocialnetwork));
        }
        //
        // GET: /UserSocialNetworks/Details/5

        public ViewResult Details(int id)
        {
            UserSocialNetwork usersocialnetwork = context.UserSocialNetworks.Single(x => x.ID == id);

            return(View(usersocialnetwork));
        }