Exemplo n.º 1
0
        public async Task <ActionResult> Edit(int id)
        {
            CodeRepository codeRepo;
            CodeView       view = new CodeView()
            {
                Code = new Code()
                {
                    Active = true
                }, CodeCategories = new List <CodeCategory>()
            };

            try
            {
                using (DBConnection dbc = new DBConnection(settings.Database.ConnectionString, logger))
                {
                    codeRepo = new CodeRepository(settings, logger, dbc);

                    view.Code = await codeRepo.FindByPKView(new PrimaryKey()
                    {
                        Key = id, IsIdentity = true
                    });

                    view.CodeCategories = CodeCategory.GetList();
                }
            }
            catch (Exception ex)
            {
                throw (Exception)Activator.CreateInstance(ex.GetType(), ex.Message + ex.StackTrace);
            }

            return(View("Edit", view));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Get(int id)
        {
            CodeRepository codeRepo;
            Code           code;

            try
            {
                using (DBConnection dbc = new DBConnection(settings.Database.ConnectionString, logger))
                {
                    codeRepo = new CodeRepository(settings, logger, dbc);

                    code = await codeRepo.FindByPKView(new PrimaryKey()
                    {
                        Key = id, IsIdentity = true
                    });
                }
            }
            catch (Exception ex)
            {
                throw (Exception)Activator.CreateInstance(ex.GetType(), ex.Message + ex.StackTrace);
            }

            return(View("Details", code));
        }