Exemplo n.º 1
0
 public bool CreateOwner(OwnerCreate model)
 {
     using (var ctx = new ApplicationDbContext())
     {
         var newOwner = new Owner()
         {
             OwnerName = model.OwnerName
         };
         ctx.Owners.Add(newOwner);
         return(ctx.SaveChanges() == 1);
     }
 }
Exemplo n.º 2
0
        public ActionResult Create(OwnerCreate model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            if (new OwnerService().CreateOwner(model))
            {
                TempData["SaveResult"] = "Owner added";
                return(RedirectToAction("Index"));
            }

            ModelState.AddModelError("", "Error adding an owner");
            return(View(model));
        }
Exemplo n.º 3
0
        public IHttpActionResult Post(OwnerCreate ownerprofile)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var service = CreateOwnerService();

            if (!service.CreateOwner(ownerprofile))
            {
                return(InternalServerError());
            }

            return(Ok());
        }
Exemplo n.º 4
0
        public bool CreateOwner(OwnerCreate model)
        {
            var entity =
                new Owner()
            {
                Id          = _Id,
                ProfileId   = model.ProfileId,
                ProfileName = model.ProfileName,
                Phone       = model.Phone,
                Email       = model.Email,
                Created     = DateTime.Now
            };

            using (var ctx = new ApplicationDbContext())
            {
                ctx.Owners.Add(entity);
                return(ctx.SaveChanges() == 1);
            }
        }