Exemplo n.º 1
0
        public async Task <ActionResult> Create(/*[Bind(Include = "Name,CardPAN,Description,SinkNodeId")]*/ routesViewModel routes)
        {
            if (ModelState.IsValid)
            {
                var obj = new Routes()
                {
                    CardPAN     = routes.CardPAN,
                    Description = routes.Description,
                    Name        = routes.Name
                };
                obj.Id       = Guid.NewGuid();
                obj.SinkNode = await _sinkNodeService.GetByIdAsync(routes.SinkNodeId);

                await _routeService.SaveAsync(obj);

                //db.Routes.Add(routes);
                //await db.SaveChangesAsync();
                return(RedirectToAction("Index"));
            }

            return(View(routes));
        }
Exemplo n.º 2
0
        public async Task <ActionResult> Edit(/*[Bind(Include="Id,Name,CardPAN,Description,SinkNode")]*/ routesViewModel routes)
        {
            if (ModelState.IsValid)
            {
                // db.Entry(routes).State = EntityState.Modified;
                Routes obj = routes.ConvertToEntityModel();
                obj.SinkNode = await _sinkNodeService.GetByIdAsync(routes.SinkNodeId);

                await _routeService.UpdateAsync(obj);//db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(routes));
        }