static public async Task <EDeliveryProductCategory> GetByID(string id)
        {
            using (var context = new SMySQLContext()) {
                EDeliveryProductCategory eCategory = await context.DeliveryProductCategories.SingleOrDefaultAsync(x => x.id == id);

                return(eCategory);
            }
        }
        static public async Task <bool> Remove(string id)
        {
            using (var context = new SMySQLContext()) {
                EDeliveryProductCategory eCategory = context.DeliveryProductCategories.SingleOrDefault(x => x.id == id);
                if (eCategory == null)
                {
                    return(false);
                }
                context.Remove(eCategory);
                await context.SaveChangesAsync();

                return(true);
            }
        }
        //=====================================================GETS ABOVE=====================================================

        #region Save
        static public async Task <string> Save(EDeliveryProductCategory eCategory)
        {
            using (var context = new SMySQLContext()) {
                if (string.IsNullOrEmpty(eCategory.id))
                {
                    eCategory.id = Guid.NewGuid().ToString();
                    var e = await context.DeliveryProductCategories.AddAsync(eCategory);

                    await context.SaveChangesAsync();

                    return(e.Entity.id);
                }
                else
                {
                    var e = context.DeliveryProductCategories.Update(eCategory);
                    await context.SaveChangesAsync();

                    return(e.Entity.id);
                }
            }
        }
Ejemplo n.º 4
0
        public async Task <IActionResult> Save([FromBody] EDeliveryProductCategory eCategory)
        {
            string id = await SDeliveryProductsCategories.Save(eCategory);

            return(Ok(id));
        }
Ejemplo n.º 5
0
        public async Task <IActionResult> GetByID(string id)
        {
            EDeliveryProductCategory eDeliveryProduct = await SDeliveryProductsCategories.GetByID(id);

            return(Ok(eDeliveryProduct));
        }