Exemplo n.º 1
0
        public ActionResult Edit(int id)
        {
            try
            {
                using (Web.UsuarioProxy.UsuarioServiceClient proxy = new UsuarioProxy.UsuarioServiceClient())
                {
                    var list = proxy.List(id);

                    // primeiro localiza o registro antes de ir para a pagina
                    if (list.Length > 0)
                    {
                        return(View(list.FirstOrDefault()));
                    }
                    else
                    {
                        return(RedirectToAction("Index"));
                    }
                }
            }
            catch (Exception ex)
            {
                Utils.HelperLog.WriteText(ex, "UsuarioController.Edit[GET]");
                return(RedirectToAction("Index"));
            }
        }
Exemplo n.º 2
0
        public ActionResult Edit(int id)
        {
            try
            {
                using (Web.UsuarioProxy.UsuarioServiceClient proxy = new UsuarioProxy.UsuarioServiceClient())
                {
                    var list = proxy.List(id);

                    // primeiro localiza o registro antes de ir para a pagina
                    if (list.Length > 0)
                    {
                        return View(list.FirstOrDefault());
                    }
                    else
                    {
                        return RedirectToAction("Index");
                    }
                }
            }
            catch (Exception ex)
            {
                Utils.HelperLog.WriteText(ex, "UsuarioController.Edit[GET]");
                return RedirectToAction("Index");
            }
        }
Exemplo n.º 3
0
 public ActionResult Add(Model.UsuarioModel model)
 {
     try
     {
         if (ModelState.IsValid)
         {
             using (Web.UsuarioProxy.UsuarioServiceClient proxy = new UsuarioProxy.UsuarioServiceClient())
             {
                 var temp = proxy.Find(model.Login);
                 if (temp.Length == 0)
                 {
                     proxy.Add(model);
                     return RedirectToAction("Index");
                 }
                 else
                 {
                     ModelState.AddModelError("Login", "Login já existe");
                 }
             }
         }
     }
     catch (Exception ex)
     {
         Utils.HelperLog.WriteText(ex, "UsuarioController.Add[POST]");
     }
     return View(model);
 }
Exemplo n.º 4
0
 public ActionResult Add(Model.UsuarioModel model)
 {
     try
     {
         if (ModelState.IsValid)
         {
             using (Web.UsuarioProxy.UsuarioServiceClient proxy = new UsuarioProxy.UsuarioServiceClient())
             {
                 var temp = proxy.Find(model.Login);
                 if (temp.Length == 0)
                 {
                     proxy.Add(model);
                     return(RedirectToAction("Index"));
                 }
                 else
                 {
                     ModelState.AddModelError("Login", "Login já existe");
                 }
             }
         }
     }
     catch (Exception ex)
     {
         Utils.HelperLog.WriteText(ex, "UsuarioController.Add[POST]");
     }
     return(View(model));
 }
Exemplo n.º 5
0
 public ActionResult Delete(int id)
 {
     try
     {
         using (Web.UsuarioProxy.UsuarioServiceClient proxy = new UsuarioProxy.UsuarioServiceClient())
         {
             proxy.Delete(id);
         }
     }
     catch (Exception ex)
     {
         Utils.HelperLog.WriteText(ex, "UsuarioController.Delete");
     }
     return RedirectToAction("Index");
 }
Exemplo n.º 6
0
 public ActionResult Delete(int id)
 {
     try
     {
         using (Web.UsuarioProxy.UsuarioServiceClient proxy = new UsuarioProxy.UsuarioServiceClient())
         {
             proxy.Delete(id);
         }
     }
     catch (Exception ex)
     {
         Utils.HelperLog.WriteText(ex, "UsuarioController.Delete");
     }
     return(RedirectToAction("Index"));
 }
Exemplo n.º 7
0
        public ActionResult Edit(Model.UsuarioModel model)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    using (Web.UsuarioProxy.UsuarioServiceClient proxy = new UsuarioProxy.UsuarioServiceClient())
                    {
                        proxy.Update(model);
                    }

                    return(RedirectToAction("Index"));
                }
            }
            catch (Exception ex)
            {
                Utils.HelperLog.WriteText(ex, "UsuarioController.Edit[POST]");
            }
            return(View(model));
        }
Exemplo n.º 8
0
        public ActionResult Index()
        {
            List <Model.UsuarioModel> list = new List <Model.UsuarioModel>();

            try
            {
                using (Web.UsuarioProxy.UsuarioServiceClient proxy = new UsuarioProxy.UsuarioServiceClient())
                {
                    var temp = proxy.List(0);
                    if (temp != null)
                    {
                        list.AddRange(temp);
                    }
                }
            }
            catch (Exception ex)
            {
                Utils.HelperLog.WriteText(ex, "UsuarioController.Index");
            }
            return(View(list));
        }
Exemplo n.º 9
0
        public ActionResult Edit(Model.UsuarioModel model)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    using (Web.UsuarioProxy.UsuarioServiceClient proxy = new UsuarioProxy.UsuarioServiceClient())
                    {
                        proxy.Update(model);
                    }

                    return RedirectToAction("Index");
                }
            }
            catch (Exception ex)
            {
                Utils.HelperLog.WriteText(ex, "UsuarioController.Edit[POST]");
            }
            return View(model);
        }
Exemplo n.º 10
0
 public ActionResult Index()
 {
     List<Model.UsuarioModel> list = new List<Model.UsuarioModel>();
     try
     {
         using (Web.UsuarioProxy.UsuarioServiceClient proxy = new UsuarioProxy.UsuarioServiceClient())
         {
             var temp = proxy.List(0);
             if (temp != null)
             {
                 list.AddRange(temp);
             }
         }
     }
     catch (Exception ex)
     {
         Utils.HelperLog.WriteText(ex, "UsuarioController.Index");
     }
     return View(list);
 }