Ejemplo n.º 1
0
        public bool CreateBio(BioCreate model)
        {
            var entity =
                new Bio()
            {
                OwnerId   = _userId,
                FullName  = model.FullName,
                NickNames = model.NickNames,
                Birthday  = model.Birthday,
                Age       = model.Age,
                Gender    = model.Gender,
                Location  = model.Location,
                Race      = model.Race,
                Ethnicity = model.Ethnicity,
                AboutYou  = model.AboutYou,
                Interests = model.Interests,
                Hobbies   = model.Hobbies,

                CreatedUtc = DateTimeOffset.Now
            };

            using (var ctx = new ApplicationDbContext())
            {
                ctx.Bios.Add(entity);
                return(ctx.SaveChanges() == 1);
            }
        }
Ejemplo n.º 2
0
        public ActionResult Create(BioCreate model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var service = CreateBioService();

            if (service.CreateBio(model))
            {
                TempData["SaveResult"] = "Your Bio has been added.";
                return(RedirectToAction("Index"));
            }

            ModelState.AddModelError("", "Your Bio could not bee added");

            return(View(model));
        }