Ejemplo n.º 1
0
        //Método para Refrescar la información de la tabla

        private void RefreshDataGridView()
        {
            List <CategoryForm> categories = BusinessCategory.GetAllCategories().ToList();

            this.dtgridCatgory.DataSource = categories;
            DisabledFields();
        }
Ejemplo n.º 2
0
        public async Task <ActionResult <BusinessCategory> > PostBusinessCategory(BusinessCategory businessCategory)
        {
            _context.businessCategories.Add(businessCategory);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetBusinessCategory", new { id = businessCategory.Id }, businessCategory));
        }
Ejemplo n.º 3
0
        //Método para insertar categoría

        private void btInsert_Click(object sender, EventArgs e)
        {
            bool isValid = ValidateField();

            if (isValid)
            {
                CategoryForm category = new CategoryForm
                {
                    CategoryName        = this.txtInsertarCategoria.Text,
                    CategoryDescription = this.txtInsertarDescripcion.Text,
                    CategoryId          = Guid.NewGuid()
                };

                bool hasBeenInserted = BusinessCategory.InsertCategory(category);

                if (hasBeenInserted)
                {
                    RefreshDataGridView();
                    MessageBox.Show("Categoría insertada correctamente");
                    CleanFieldsInserted();
                }
                else
                {
                    MessageBox.Show("Error al insertar categoria");
                }
            }
        }
Ejemplo n.º 4
0
        // Método para actualizar categoría

        private void button1_Click(object sender, EventArgs e)
        {
            bool isValid = ValidateFieldUpdate();

            if (!isValid)
            {
                return;
            }

            CategoryForm category = new CategoryForm
            {
                CategoryName        = this.txtCategoryName.Text,
                CategoryDescription = this.txtDescripcion.Text,
                CategoryId          = new Guid(this.lbId.Text),
            };
            bool isUpdated = BusinessCategory.UpdateCategory(category);

            if (isUpdated)
            {
                RefreshDataGridView();
                CleanFields();
                MessageBox.Show("Categoría actualizada correctamente");
            }
            else
            {
                MessageBox.Show("Ha ocurrido un error actualizando los campos de la categoría");
            }
        }
Ejemplo n.º 5
0
        public async Task <IActionResult> PutBusinessCategory(int id, BusinessCategory businessCategory)
        {
            if (id != businessCategory.Id)
            {
                return(BadRequest());
            }

            _context.Entry(businessCategory).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!BusinessCategoryExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Ejemplo n.º 6
0
        public ActionResult ListCategories()
        {
            var target  = new BusinessCategory();
            var retorno = target.GetAllCategories();

            return(Json(retorno, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 7
0
        private void Subcategories_Load(object sender, EventArgs e)
        {
            RefreshDataGridView();
            IEnumerable <DataAccess.Entities.Category> categories = BusinessCategory.GetAllCategories().ToList();

            comboInsert.DataSource    = categories;
            comboInsert.DisplayMember = "CategoryName";
            comboInsert.ValueMember   = "CategoryId";
        }
        public async Task <ActionResult> DeleteConfirmed(int id)
        {
            BusinessCategory businessCategory = await db.BusinessCategories.FindAsync(id);

            db.BusinessCategories.Remove(businessCategory);
            await db.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }
Ejemplo n.º 9
0
 public DAO.BusinessCategory CreateBusinessCategory(BusinessCategory businessCategory)
 {
     return(new DAO.BusinessCategory()
     {
         Description = businessCategory.Description,
         CategoryName = businessCategory.CategoryName,
         Id = businessCategory.Id,
         Businesses = businessCategory.Businesses.Select(b => businessFactory.CreateBusiness(b)).ToList()
     });
 }
        public async Task <ActionResult> Edit([Bind(Include = "BusinessCategoryID,Title,Description,CompanyID")] BusinessCategory businessCategory)
        {
            if (ModelState.IsValid)
            {
                db.Entry(businessCategory).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            ViewBag.CompanyID = new SelectList(db.Companies, "CompanyID", "CompanyName", businessCategory.CompanyID);
            return(View(businessCategory));
        }
Ejemplo n.º 11
0
        public void Post([FromBody] Business value)

        {
            var imageString = value.ImageUrl;
            var imageUrls   = HttpHelper.getImageName("bussines");

            value.ImageUrl = imageUrls.imageUrl;

            using (var transaction = _db.Database.BeginTransaction())
            {
                value.BusinesCategories = new List <BusinessCategory>();
                foreach (var item in value.Categories)
                {
                    if (item.Id > 0)
                    {
                        _db.ProductCategories.Attach(item);
                        _db.Entry(item).State = EntityState.Unchanged;
                    }
                    else
                    {
                        _db.ProductCategories.Add(item);
                        _db.SaveChanges();
                    }

                    var busCat = new BusinessCategory()
                    {
                        Bussiness         = value,
                        BussinessId       = value.Id,
                        ProductCategory   = item,
                        ProductCategoryId = item.Id
                    };
                    value.BusinesCategories.Add(busCat);
                }

                try
                {
                    _db.SaveChanges();
                    transaction.Commit();
                }
                catch (Exception ex)
                {
                    transaction.Rollback();
                    throw ex;
                }
            }

            _db.Businesses.Add(value);
            _db.SaveChanges();


            ImageUtility.SaveImage(imageUrls.imageDir, imageString);
        }
        public async Task <ActionResult> Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            BusinessCategory businessCategory = await db.BusinessCategories.FindAsync(id);

            if (businessCategory == null)
            {
                return(HttpNotFound());
            }
            return(View(businessCategory));
        }
Ejemplo n.º 13
0
        /// <summary>
        /// Converts a BusinessCategory value to a corresponding string value
        /// </summary>
        /// <param name="enumValue">The BusinessCategory value to convert</param>
        /// <returns>The representative string value</returns>
        public static string ToValue(BusinessCategory enumValue)
        {
            switch (enumValue)
            {
            //only valid enum elements can be used
            //this is necessary to avoid errors
            case BusinessCategory.NOT_PROVIDED:
            case BusinessCategory.ARTS_CRAFTS_AND_COLLECTIBLES:
            case BusinessCategory.BABY:
            case BusinessCategory.BEAUTY_AND_FRAGRANCES:
            case BusinessCategory.BOOKS_AND_MAGAZINES:
            case BusinessCategory.BUSINESS_TO_BUSINESS:
            case BusinessCategory.CLOTHING_ACCESSORIES_AND_SHOES:
            case BusinessCategory.COMPUTERS_ACCESSORIES_AND_SERVICES:
            case BusinessCategory.EDUCATION:
            case BusinessCategory.ELECTRONICS_AND_TELECOM:
            case BusinessCategory.ENTERTAINMENT_AND_MEDIA:
            case BusinessCategory.FINANCIAL_SERVICES_AND_PRODUCTS:
            case BusinessCategory.FOOD_RETAIL_AND_SERVICE:
            case BusinessCategory.GIFTS_AND_FLOWERS:
            case BusinessCategory.HEALTH_AND_PERSONAL_CARE:
            case BusinessCategory.HOME_AND_GARDEN:
            case BusinessCategory.NONPROFIT:
            case BusinessCategory.PETS_AND_ANIMALS:
            case BusinessCategory.RELIGION_AND_SPIRITUALITY_FOR_PROFIT:
            case BusinessCategory.RETAIL_NOT_ELSEWHERE_CLASSIFIED:
            case BusinessCategory.SERVICES_OTHER:
            case BusinessCategory.SPORTS_AND_OUTDOORS:
            case BusinessCategory.TOYS_AND_HOBBIES:
            case BusinessCategory.TRAVEL:
            case BusinessCategory.VEHICLE_SERVICE_AND_ACCESSORIES:
            case BusinessCategory.PROFESSIONAL_SERVICES:
            case BusinessCategory.RETAIL_BARS_AND_RESTAURANTS:
            case BusinessCategory.ENTERTAINMENT_AND_TRAVEL:
            case BusinessCategory.HEALTH_AND_SOCIAL_CARE:
            case BusinessCategory.TRANSPORT_AND_VEHICLES:
            case BusinessCategory.CONSTRUCTION_TRADES_AND_CLEANING:
            case BusinessCategory.PROPERTY:
            case BusinessCategory.EXERCISE_AND_FITNESS:
            case BusinessCategory.EDUCATION_AND_SKILLS:
            case BusinessCategory.NON_PROFIT1:
            case BusinessCategory.MANUFACTURING_RND_AND_AGRICULTURE:
                return(StringValues[(int)enumValue]);

            //an invalid enum value was requested
            default:
                return(null);
            }
        }
        // GET: BusinessCategories/Edit/5
        public async Task <ActionResult> Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            BusinessCategory businessCategory = await db.BusinessCategories.FindAsync(id);

            if (businessCategory == null)
            {
                return(HttpNotFound());
            }
            ViewBag.CompanyID = new SelectList(db.Companies, "CompanyID", "CompanyName", businessCategory.CompanyID);
            return(View(businessCategory));
        }
Ejemplo n.º 15
0
        // Method for  grid update for GridCategory
        protected void GridCategory_BatchUpdate(object sender, ASPxDataBatchUpdateEventArgs e)
        {
            var listInsert = new List <BusinessCategory>();

            foreach (var args in e.InsertValues)
            {
                //InsertNewItem(args.NewValues);
                BusinessCategory category = new BusinessCategory();
                category.AreaID        = Convert.ToString(args.NewValues["AreaID"]);
                category.UniqueID      = Convert.ToString(args.NewValues["UniqueID"]);
                category.CategoryTitle = Convert.ToString(args.NewValues["CategoryTitle"]);
                category.Description   = Convert.ToString(args.NewValues["Description"]);
                category.Source        = Convert.ToString(args.NewValues["Source"]);
                category.Date          = Convert.ToDateTime(args.NewValues["Date"]);
                listInsert.Add(category);
            }
            if (listInsert.Count > 0)
            {
                rtm_services.InsertNewBusinessCategory(listInsert);
            }
            var listUpdates = new List <BusinessCategory>();

            foreach (var args in e.UpdateValues)
            {
                BusinessCategory category = new BusinessCategory();
                category.Id            = Convert.ToString(args.Keys["Id"]);
                category.UniqueID      = Convert.ToString(args.NewValues["UniqueID"]);
                category.CategoryTitle = Convert.ToString(args.NewValues["CategoryTitle"]);
                category.Description   = Convert.ToString(args.NewValues["Description"]);
                category.Source        = Convert.ToString(args.NewValues["Source"]);
                category.Date          = Convert.ToDateTime(args.NewValues["Date"]);

                listUpdates.Add(category);
            }
            if (listUpdates.Count > 0)
            {
                rtm_services.UpdateBusinessCategory(listUpdates);
            }

            foreach (var args in e.DeleteValues)
            {
                DeleteCategoryItem(args.Keys);
            }
            e.Handled = true;
            BindCategory();
            BindProcess(ddlProjects.SelectedItem.Value.ToString());
        }
Ejemplo n.º 16
0
        // Método para editar una subcategoria

        private void SubcategoryClick(object sender, DataGridViewCellEventArgs e)
        {
            EnabledFields();
            IEnumerable <DataAccess.Entities.Category> categories = BusinessCategory.GetAllCategories().ToList();

            comboSubcategory.DataSource    = categories;
            comboSubcategory.DisplayMember = "CategoryName";
            comboSubcategory.ValueMember   = "CategoryId";

            var rows = this.dtgridSubcatgory.CurrentRow;

            if (rows != null)
            {
                this.txtSubcategoryName.Text        = rows.Cells["SubcategoryName"].Value.ToString();
                this.txtSubcategoryDescripcion.Text = rows.Cells["SubcategoryDescription"].Value.ToString();
                this.lbId.Text             = rows.Cells["SubcategoryId"].Value.ToString();
                this.comboSubcategory.Text = rows.Cells["Category"].Value.ToString();
            }
            else
            {
                MessageBox.Show("Selecciona una fila");
            }
        }
Ejemplo n.º 17
0
        // Método para eliminar categoría

        private void button3_Click(object sender, EventArgs e)
        {
            var rows = this.dtgridCatgory.CurrentRow;

            if (rows != null)
            {
                var isDeleted = BusinessCategory.DeleteCategory(new Guid(rows.Cells["CategoryId"].Value.ToString()));

                if (isDeleted)
                {
                    RefreshDataGridView();
                    CleanFields();
                    MessageBox.Show("Categoría borrada correctamente");
                }
                else
                {
                    MessageBox.Show("Error borrando categoría");
                }
            }
            else
            {
                MessageBox.Show("Debe seleccionar una fila que borrar");
            }
        }
Ejemplo n.º 18
0
        // Método para buscar categoría

        private void SearchCategory(object sender, EventArgs e)
        {
            this.dtgridCatgory.DataSource = BusinessCategory.SearchCategory(this.txtSearch.Text);
        }
Ejemplo n.º 19
0
        protected override void Seed(VotingContext context)
        {
            var groups = new List <Category>
            {
                new Category {
                    CategoryID = 0, Title = "Solutioneers Features", Description = "Craving a new feature on the site? Submit it here and we will do our best to make sure all the top voted ideas get integrated into our systems!"
                },
                new Category {
                    CategoryID = 1, Title = "Business", Description = "Some important shit here"
                },
                new Category {
                    CategoryID = 2, Title = "Comics", Description = "Some important shit here"
                },
                new Category {
                    CategoryID = 3, Title = "Communication", Description = "Some important shit here"
                },
                new Category {
                    CategoryID = 4, Title = "Education", Description = "Some important shit here"
                },
                new Category {
                    CategoryID = 5, Title = "Entertainment", Description = "Some important shit here"
                },
                new Category {
                    CategoryID = 6, Title = "Finance", Description = "Some important shit here"
                },
                new Category {
                    CategoryID = 7, Title = "Health & Fitness", Description = "Some important shit here"
                },
                new Category {
                    CategoryID = 8, Title = "Lifestyle", Description = "Some important shit here"
                },
                new Category {
                    CategoryID = 9, Title = "Media & Video", Description = "Some important shit here"
                },
                new Category {
                    CategoryID = 10, Title = "Medical", Description = "Some important shit here"
                },
                new Category {
                    CategoryID = 11, Title = "Music & Audio", Description = "Some important shit here"
                },
                new Category {
                    CategoryID = 12, Title = "News & Magazines", Description = "Some important shit here"
                },
                new Category {
                    CategoryID = 13, Title = "Photography", Description = "Some important shit here"
                },
                new Category {
                    CategoryID = 14, Title = "Productivity", Description = "Some important shit here"
                },
                new Category {
                    CategoryID = 15, Title = "Shopping", Description = "Some important shit here"
                },
                new Category {
                    CategoryID = 16, Title = "Social", Description = "Some important shit here"
                },
                new Category {
                    CategoryID = 17, Title = "Sports", Description = "Some important shit here"
                },
                new Category {
                    CategoryID = 18, Title = "Tools", Description = "Some important shit here"
                },
                new Category {
                    CategoryID = 19, Title = "Transportation", Description = "Some important shit here"
                },
                new Category {
                    CategoryID = 20, Title = "Travel & Local", Description = "Some important shit here"
                },
                new Category {
                    CategoryID = 21, Title = "Weather", Description = "Some important shit here"
                }
            };

            groups.ForEach(s => context.Categories.Add(s));

            for (int i = 0, j = 0; i < 10; i++)
            {
                Company populate = new Company();
                populate.CompanyID    = i;
                populate.CreationDate = DateTime.Now;
                populate.Description  = "This is some dummy description number: " + i;
                populate.CompanyName  = "Company No: " + i;
                populate.UserID       = "Admin Dummy Data";

                Location tempLocation = new Location();
                tempLocation.LocationID       = i;
                tempLocation.Phone            = "1111111111";
                tempLocation.StreetAddress1   = "1234 Someplace NW ST";
                tempLocation.State            = Enums.State.WA;
                tempLocation.ZipCode          = "98402";
                tempLocation.City             = "Seattle";
                tempLocation.CompanyID        = populate.CompanyID;
                tempLocation.Company          = populate;
                tempLocation.HoursOfOperation = new List <HoursOfOperation>();

                BusinessCategory tempBizCat = new BusinessCategory();
                tempBizCat.BusinessCategoryID = i;
                tempBizCat.Company            = populate;
                tempBizCat.Description        = "This is a dummy description for a biz cat" + i;
                tempBizCat.CompanyID          = populate.CompanyID;
                tempBizCat.Title = "BusinessCategory Temp Holder" + i;


                populate.Locations = new List <Location> {
                    tempLocation
                };
                populate.BusinessCategories = new List <BusinessCategory> {
                    tempBizCat
                };

                /*
                 * HoursOfOperation tempHours = new HoursOfOperation();
                 * tempHours.HoursOfOperationID = i;
                 * tempHours.DayOfWeek = DayOfWeek.Friday;
                 * tempHours.LocationID = tempLocation.LocationID;
                 * tempHours.Location = tempLocation;
                 * tempHours.TimeOpen = "9 AM - 5 PM";
                 *
                 * tempLocation.HoursOfOperation.Concat(new List<HoursOfOperation> { tempHours });
                 * populate.Locations.Concat(new List<Location>{ tempLocation });
                 *
                 *
                 * context.HoursOfOperations.Add(tempHours);*/

                context.BusinessCategories.Add(tempBizCat);
                context.Locations.Add(tempLocation);
                context.Companies.Add(populate);
            }
            context.SaveChanges();
        }
Ejemplo n.º 20
0
 public BookingRepositoryActionResult <BusinessCategory> InsertBusinessCategory(BusinessCategory bc)
 {
     try
     {
         _ctx.BusinessCategories.Add(bc);
         var result = _ctx.SaveChanges();
         if (result > 0)
         {
             return(new BookingRepositoryActionResult <BusinessCategory>(bc, BookingRepositoryActionStatus.Created));
         }
         else
         {
             return(new BookingRepositoryActionResult <BusinessCategory>(bc, BookingRepositoryActionStatus.NothingModified, null));
         }
     }
     catch (Exception ex)
     {
         return(new BookingRepositoryActionResult <BusinessCategory>(null, BookingRepositoryActionStatus.Error, ex));
     }
 }
Ejemplo n.º 21
0
 public object CreateDataShapedObject(BusinessCategory businessCategory, List <string> lstOfFields)
 {
     return(CreateDataShapedObject(CreateBusinessCategory(businessCategory), lstOfFields));
 }
Ejemplo n.º 22
0
        public BookingRepositoryActionResult <BusinessCategory> UpdateBusinessCategory(BusinessCategory eg)
        {
            try
            {
                // you can only update when an expensegroup already exists for this id

                var existingEG = _ctx.BusinessCategories.FirstOrDefault(exg => exg.Id == eg.Id);

                if (existingEG == null)
                {
                    return(new BookingRepositoryActionResult <BusinessCategory>(eg, BookingRepositoryActionStatus.NotFound));
                }

                // change the original entity status to detached; otherwise, we get an error on attach
                // as the entity is already in the dbSet

                // set original entity state to detached
                _ctx.Entry(existingEG).State = EntityState.Detached;

                // attach & save
                _ctx.BusinessCategories.Attach(eg);

                // set the updated entity state to modified, so it gets updated.
                _ctx.Entry(eg).State = EntityState.Modified;


                var result = _ctx.SaveChanges();
                if (result > 0)
                {
                    return(new BookingRepositoryActionResult <BusinessCategory>(eg, BookingRepositoryActionStatus.Updated));
                }
                else
                {
                    return(new BookingRepositoryActionResult <BusinessCategory>(eg, BookingRepositoryActionStatus.NothingModified, null));
                }
            }
            catch (Exception ex)
            {
                return(new BookingRepositoryActionResult <BusinessCategory>(null, BookingRepositoryActionStatus.Error, ex));
            }
        }