Exemplo n.º 1
0
 public ActionResult OnPost()
 {
     if (!ModelState.IsValid)
     {
         Clients = _torresCafeDBContext.Clients.ToList();
         return(Page());
     }
     _torresCafeDBContext.Clients.Add(Client);
     _torresCafeDBContext.SaveChanges();
     return(Redirect("/index"));
 }
Exemplo n.º 2
0
        public ActionResult OnPost()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            //var clnt = _torrescafedbcontext.Clients.FirstOrDefault(client => client.ClientId == Client.ClientId);
            Client clnt = new Client();

            clnt = _torrescafedbcontext.Clients.FirstOrDefault(client => client.ClientId == Client.ClientId);
            if (clnt != null)
            {
                clnt.ClientName         = Client.ClientName;
                clnt.ClientAge          = Client.ClientAge;
                clnt.ClientContactNo    = Client.ClientContactNo;
                clnt.ClientEmailAdd     = Client.ClientEmailAdd;
                clnt.ClientSubscription = Client.ClientSubscription;
                clnt.ClientAddress      = Client.ClientAddress;

                _torrescafedbcontext.Update(clnt);
                _torrescafedbcontext.SaveChanges();
            }
            return(Redirect("Client"));
        }