Ejemplo n.º 1
0
        /// <summary>
        /// Edits the specified identifier.
        /// </summary>
        /// <param name="id">The identifier.</param>
        /// <returns>ActionResult.</returns>
        public ActionResult Edit(int id)
        {
            var model = new BodyPartViewModel();

            if (id != -1)
            {
                var svc = new BodyPartAppService();
                var o = svc.GetBodyPart(id);
                model.BodyPartId = o.BodyPartId;
                model.Name = o.Name;
            

            }
            else
            {
                model.Action = "-1";
                model.BodyPartId = -1;
                model.Name = string.Empty;
                
            }



            return View(model);
        }
Ejemplo n.º 2
0
        public ActionResult Edit(BodyPartViewModel model)
        {



            try
            {
                var svc = new BodyPartAppService();

                var o = new BodyPart
                {
                    BodyPartId= model.BodyPartId,
                    Name = model.Name,
                    

                };

                if (model.Action == "-1")
                {
                    var exist = svc.GetBodyPart(model.BodyPartId)!=null;
                    if (!exist)
                    {
                        svc.AddBodyPart(o);
                        ViewBag.Feed = 0;
                    }
                    else
                    {
                        model.Action = "-1";
                        ViewBag.Feed = 3;
                        return View(model);
                    }
                }
                else
                {
                    o.BodyPartId= model.BodyPartId;
                    if (model.IsDeleteAction == 0)
                    {

                        svc.SaveBodyPart(o);
                    }
                    else
                    {
                        svc.RemoveBodyPart(model.BodyPartId);
                    }
                    ViewBag.Feed = 0;
                }
            }
            catch (Exception)
            {
                ViewBag.Feed = 1;

            }

            return View(model);
        }
Ejemplo n.º 3
0
        public DataTablesResult<BodyPartViewModel> GetAllRecords(DataTablesParam dataTableParam)
        {

            var svc = new BodyPartAppService();
            var lst = svc.GetAllBodyPart();
            var lstVm = new List<BodyPartViewModel>();
            foreach (var itm in lst)
            {

                var itmVm = new BodyPartViewModel
                {

                    Name = itm.Name,
                    BodyPartId= itm.BodyPartId,

                };

              




                var sb = new StringBuilder();

                string editUrl = Url.Action("Edit", "BodyPart");
                sb.AppendLine("<div class=\"btn-group\">");
                sb.AppendLine(
                    "<button type=\"button\" class=\"btn btn-default dropdown-toggle\" data-toggle=\"dropdown\" aria-expanded=\"false\">");
                sb.AppendLine("Acciones <span class=\"caret\"></span>");
                sb.AppendLine("</button>");
                sb.AppendLine("<ul class=\"dropdown-menu\" role=\"menu\">");
                sb.AppendLine("<li><a href=\"" + editUrl + "?id=-1\"><i class=\"fa fa-plus\"></i>&nbsp;Nuevo Registro</a></li>");
                sb.AppendLine("<li><a href=\"" + editUrl + "?id=" + itmVm.BodyPartId+ "\"><i class=\"fa fa-edit\"></i>&nbsp;Editar " + itmVm.Name + "</a></li>");
                sb.AppendLine("</ul>");
                sb.AppendLine("</div>");






                var actionButton = sb.ToString();

                itmVm.ActionButton = actionButton;
                lstVm.Add(itmVm);

            }

            var lstVmQueryable = lstVm.AsQueryable();


            return DataTablesResult.Create(lstVmQueryable, dataTableParam);

        }