Exemple #1
0
 public ActionResult Edit([Bind(Include = "ID,First_name,Last_name,CPF,Email,Login,Password,Created,Updated")] UserEntity userEntity)
 {
     if (ModelState.IsValid)
     {
         using (Repository <UserEntity> rep = new RepositoryUser())
         {
             rep.Add(userEntity);
             rep.SaveAll();
         }
         return(RedirectToAction("Index"));
     }
     return(View(userEntity));
 }
 public HttpResponseMessage Delete(HttpRequestMessage request, int id)
 {
     try
     {
         using (RepositoryUser rep = new RepositoryUser())
         {
             rep.Delete((p => p.ID == id));
             rep.SaveAll();
             return(request.CreateResponse(HttpStatusCode.Accepted));
         }
     }
     catch (Exception e)
     {
         return(request.CreateErrorResponse(HttpStatusCode.BadRequest, e.Message));
     }
 }
 public HttpResponseMessage Update(HttpRequestMessage request, UserEntity user)
 {
     try
     {
         using (RepositoryUser rep = new RepositoryUser())
         {
             rep.Update(user);
             rep.SaveAll();
             return(request.CreateResponse(HttpStatusCode.Accepted, user));
         }
     }
     catch (Exception e)
     {
         return(request.CreateErrorResponse(HttpStatusCode.BadRequest, e.Message));
     }
 }