Beispiel #1
0
        private void BrandAdd_Click(object sender, EventArgs e)
        {
            BrandForm form = new BrandForm();

            form.FormClosed += new FormClosedEventHandler(this.OnFormClose);
            form.Show();
        }
Beispiel #2
0
        private void BrandEdit_Click(object sender, EventArgs e)
        {
            int index = brandGridView.SelectedCells.Count > 0 ? brandGridView.SelectedCells[0].RowIndex : -1;

            index = index != -1 ? Int32.Parse(brandGridView.Rows[index].Cells[0].Value.ToString()) : 0;
            BrandForm form = new BrandForm(index);

            form.FormClosed += new FormClosedEventHandler(this.OnFormClose);
            form.Show();
        }
Beispiel #3
0
        public IActionResult Get(long id)
        {
            var brand = _brandRepository.Query().FirstOrDefault(x => x.Id == id);
            var model = new BrandForm
            {
                Id          = brand.Id,
                Name        = brand.Name,
                IsPublished = brand.IsPublished
            };

            return(Json(model));
        }
        public async Task <IActionResult> Post([FromBody] BrandForm model)
        {
            var brand = new Brand
            {
                Name        = model.Name,
                Slug        = model.Slug,
                IsPublished = model.IsPublished
            };

            await _brandService.Create(brand);

            return(CreatedAtAction(nameof(Get), new { id = brand.Id }, null));
        }
Beispiel #5
0
        public async Task <IActionResult> Get(long id)
        {
            var brand = await _brandRepository.Query().FirstOrDefaultAsync(x => x.Id == id);

            var model = new BrandForm
            {
                Id          = brand.Id,
                Name        = brand.Name,
                Slug        = brand.SeoTitle,
                IsPublished = brand.IsPublished
            };

            return(Json(model));
        }
Beispiel #6
0
        public IActionResult Put(long id, [FromBody] BrandForm model)
        {
            if (ModelState.IsValid)
            {
                var brand = _brandRepository.Query().FirstOrDefault(x => x.Id == id);
                brand.Name        = model.Name;
                brand.SeoTitle    = model.Name.ToUrlFriendly();
                brand.IsPublished = model.IsPublished;

                _brandService.Update(brand);

                return(Ok());
            }

            return(new BadRequestObjectResult(ModelState));
        }
Beispiel #7
0
        public async Task <IActionResult> Post([FromBody] BrandForm model)
        {
            if (ModelState.IsValid)
            {
                var brand = new Brand
                {
                    Name        = model.Name,
                    SeoTitle    = model.Slug,
                    IsPublished = model.IsPublished
                };

                await _brandService.Create(brand);

                return(CreatedAtAction(nameof(Get), new { id = brand.Id }, null));
            }
            return(BadRequest(ModelState));
        }
Beispiel #8
0
        public IActionResult Post([FromBody] BrandForm model)
        {
            if (ModelState.IsValid)
            {
                var brand = new Brand
                {
                    Name        = model.Name,
                    SeoTitle    = model.Name.ToUrlFriendly(),
                    IsPublished = model.IsPublished
                };

                _brandService.Create(brand);

                return(Ok());
            }
            return(new BadRequestObjectResult(ModelState));
        }
        public async Task <IActionResult> Put(long id, [FromBody] BrandForm model)
        {
            var brand = _brandRepository.Query().FirstOrDefault(x => x.Id == id);

            if (brand == null)
            {
                return(NotFound());
            }

            brand.Name        = model.Name;
            brand.Slug        = model.Slug;
            brand.IsPublished = model.IsPublished;

            await _brandService.Update(brand);

            return(Accepted());
        }
Beispiel #10
0
        public IActionResult Get(long id)
        {
            var brand = brandRepository.Query().FirstOrDefault(x => x.Id == id);
            var model = new BrandForm
            {
                Id = brand.Id,
                Name = brand.Name,
                IsPublished = brand.IsPublished
            };

            return Json(model);
        }
Beispiel #11
0
        private void InitForm(string mode)
        {
            Form            newForm;
            DataGridViewRow selectedRow = new DataGridViewRow();

            if (mode.Equals("Edit"))
            {
                try
                {
                    selectedRow = DgvGeneric.SelectedRows[0];
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                    MessageBox.Show(
                        text: "Debes seleccionar una fila",
                        caption: "Error",
                        buttons: MessageBoxButtons.OK,
                        icon: MessageBoxIcon.Error);
                    return;
                }
            }

            switch (activeGrid)
            {
            case 0:
                newForm = new EmployeeForm(mode, selectedRow);
                newForm.ShowDialog();
                break;

            case 1:
                newForm = new DepartmentForm(mode, selectedRow);
                newForm.ShowDialog();
                break;

            case 2:
                newForm = new ItemForm(mode, selectedRow);
                newForm.ShowDialog();
                break;

            case 3:
                newForm = new BrandForm(mode, selectedRow);
                newForm.ShowDialog();
                break;

            case 4:
                newForm = new UnitForm(mode, selectedRow);
                newForm.ShowDialog();
                break;

            case 5:
                newForm = new ProviderForm(mode, selectedRow);
                newForm.ShowDialog();
                break;

            case 6:
                newForm = new ItemRequestForm(mode, selectedRow);
                newForm.ShowDialog();
                break;

            case 7:
                newForm = new PurchaseOrderForm(mode, selectedRow);
                newForm.ShowDialog();
                break;

            case 8:
                newForm = new UserForm(mode, selectedRow);
                newForm.ShowDialog();
                break;
            }
        }