Пример #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));
 }
 private void regButton_Click(object sender, RoutedEventArgs e)
 {
     if (regLogin.Text != "" && regPswd.Text != "")
     {
         repoUser.Add(new User(regLogin.Text, regPswd.Text));
         new MainWindow().Show();
         this.Close();
     }
     else
     {
         MessageBox.Show("Поля логин и пароль должны быть заполнены");
     }
 }
 public HttpResponseMessage Save(HttpRequestMessage request, UserEntity user)
 {
     try
     {
         using (RepositoryUser rep = new RepositoryUser())
         {
             rep.Add(user);
             rep.SaveAll();
         }
         return(request.CreateResponse(HttpStatusCode.Created, user));
     }
     catch (Exception e)
     {
         return(request.CreateErrorResponse(HttpStatusCode.BadRequest, e.Message));
     }
 }