Beispiel #1
0
 public ActionResult Add(AddSockModel model, HttpPostedFileBase upload)
 {
     if (!ModelState.IsValid || upload == null)
     {
         return View(model);
     }
     _repository.Add(User.Identity.GetUserId(), model, ToByteArray(upload));
     return RedirectToAction("Index");
 }
Beispiel #2
0
        public void Add(string userId, AddSockModel model, byte[] image)
        {
            // get the user
            var u = _users.Single(x => x.Id == userId);

            // create a sock entity
            var e = new Sock
            {
                Name = model.Name,
                Description = model.Description,
                Image = image,
                DateOfBirth = DateTime.Now
            };
            u.Socks.Add(e);
            _context.SaveChanges();
        }