Exemplo n.º 1
0
        public IViewComponentResult Invoke()
        {
            var res    = repository.GetAll().FirstOrDefault();
            var number = String.Format("{0:(###) ###-####}", res.PhoneNumber);

            if (res != null)
            {
                var mainhede = new MainPersonelContextModel();
                mainhede.PersonName            = res.PersonName;
                mainhede.PersonWorkInstructure = res.PersonWorkInstructure;
                mainhede.Age                      = res.Age;
                mainhede.PhoneNumber              = res.PhoneNumber;
                mainhede.Email                    = res.Email;
                mainhede.PersonImage              = res.PersonImage;
                mainhede.Adress                   = res.Adress;
                mainhede.HelloHeaderDescription   = res.HelloHeaderDescription;
                mainhede.HelloSectionDescription  = res.HelloSectionDescription;
                mainhede.ResumeHeaderDescription  = res.ResumeHeaderDescription;
                mainhede.ResumeSectionDescription = res.ResumeSectionDescription;
                mainhede.GithubLink               = res.GithubLink;
                mainhede.LinkedikLink             = res.LinkedikLink;
                return(View(mainhede));
            }
            else
            {
                return(View());
            }
        }
Exemplo n.º 2
0
        public async Task <IActionResult> HeaderMain(MainPersonelContextModel model, IFormFile file)
        {
            var personDescription = new PersonMainDescription();

            if (ModelState.IsValid)
            {
                personDescription.PersonName            = model.PersonName;
                personDescription.PersonWorkInstructure = model.PersonWorkInstructure;
                personDescription.Age         = model.Age;
                personDescription.PhoneNumber = model.PhoneNumber;
                personDescription.Email       = model.Email;
                if (file != null)
                {
                    var path = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot\\images", file.FileName);
                    using (var stream = new FileStream(path, FileMode.Create))
                    {
                        await file.CopyToAsync(stream);

                        personDescription.PersonImage = file.FileName;
                    }
                }
                personDescription.Adress = model.Adress;
                personDescription.HelloHeaderDescription   = model.HelloHeaderDescription;
                personDescription.HelloSectionDescription  = model.HelloSectionDescription;
                personDescription.ResumeHeaderDescription  = model.ResumeHeaderDescription;
                personDescription.ResumeSectionDescription = model.ResumeSectionDescription;
                personDescription.Skype        = model.Skype;
                personDescription.GithubLink   = model.GithubLink;
                personDescription.LinkedikLink = model.LinkedikLink;
                repository.personMainDescription.Add(personDescription);
                TempData["Message"] = $"{model.PersonName} Kayıt Edildi";
                repository.SaveChanges();

                return(RedirectToAction("Index", "Admin"));
            }
            else
            {
                return(View(model));
            }
        }