コード例 #1
0
        static public EDeliveryProductOption GetByID(string id)
        {
            using var context = new SMySQLContext();
            EDeliveryProductOption eDeliveryProductOption = context.DeliveryProductOptions.SingleOrDefault(x => x.id == id);

            return(eDeliveryProductOption);
        }
コード例 #2
0
        static public async Task <bool> Remove(string id)
        {
            using var context = new SMySQLContext();
            EDeliveryProductOption eDeliveryProductOption = context.DeliveryProductOptions.SingleOrDefault(x => x.id == id);

            if (eDeliveryProductOption == null)
            {
                return(false);
            }
            context.Remove(eDeliveryProductOption);
            await context.SaveChangesAsync();

            return(true);
        }
コード例 #3
0
        static public string GetInternalNameIfAvailable(string id)
        {
            using var context = new SMySQLContext();
            EDeliveryProductOption eDeliveryProductOption = context.DeliveryProductOptions.SingleOrDefault(x => x.id == id);

            if (string.IsNullOrEmpty(eDeliveryProductOption.internalName))
            {
                return(eDeliveryProductOption.name);
            }
            else
            {
                return(eDeliveryProductOption.internalName);
            }
        }
コード例 #4
0
        //=====================================================GETS ABOVE=====================================================

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

                await context.SaveChangesAsync();

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

                return(e.Entity.id);
            }
        }
コード例 #5
0
        public IActionResult GetByID(string id)
        {
            EDeliveryProductOption eDeliveryProductOption = SDeliveryProductsOptions.GetByID(id);

            return(Ok(eDeliveryProductOption));
        }
コード例 #6
0
        public async Task <IActionResult> Save([FromBody] EDeliveryProductOption eDeliveryProductOption)
        {
            string id = await SDeliveryProductsOptions.Save(eDeliveryProductOption);

            return(Ok(id));
        }