示例#1
0
        //=====================================================GETS ABOVE=====================================================

        #region Save
        static public async Task <string> Save(ELogisticsDriverIncident eIncident)
        {
            try {
                eIncident.modificationDateUTC = DateTime.UtcNow;
                using (var context = new SMySQLContext()) {
                    if (string.IsNullOrEmpty(eIncident.id))
                    {
                        eIncident.id = Guid.NewGuid().ToString();
                        eIncident.creationDateUTC = eIncident.modificationDateUTC = DateTime.UtcNow;
                        var e = await context.LogisticsDriverIncidents.AddAsync(eIncident);

                        await context.SaveChangesAsync();

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

                        return(e.Entity.id);
                    }
                }
            } catch (DbUpdateException e) {
                Console.WriteLine(e.ToString());
                throw;
            }
        }
示例#2
0
        //=====================================================GETS ABOVE=====================================================

        #region Save
        static public async Task <string> Save(EBaseEntity eDriver)
        {
            eDriver.modificationDateUTC = DateTime.UtcNow;
            eDriver.type = EntityType.Driver;
            using (var context = new SMySQLContext()) {
                if (string.IsNullOrEmpty(eDriver.id))
                {
                    eDriver.id = Guid.NewGuid().ToString();
                    eDriver.creationDateUTC = DateTime.UtcNow;
                    var e = await context.BaseUsers.AddAsync(eDriver);

                    await context.SaveChangesAsync();

                    return(e.Entity.id);
                }
                else
                {
//                    ELogisticsDriver oldDriver = context.LogisticsDrivers.SingleOrDefault(x => x.id == eDriver.id);
//                    eDriver.password = eDriver.password;
                    var e = context.BaseUsers.Update(eDriver);
                    await context.SaveChangesAsync();

                    return(e.Entity.id);
                }
            }
        }
        //=====================================================GETS ABOVE=====================================================

        #region Save
        static public async Task <string> Save(EBaseEntity eBaseEntity)
        {
            eBaseEntity.modificationDateUTC = DateTime.UtcNow;
            eBaseEntity.type  = EntityType.Supplier;
            using var context = new SMySQLContext();
            if (string.IsNullOrEmpty(eBaseEntity.id))
            {
                eBaseEntity.id = Guid.NewGuid().ToString();
                eBaseEntity.creationDateUTC = DateTime.UtcNow;
                var e = await context.BaseUsers.AddAsync(eBaseEntity);

                await context.SaveChangesAsync();

                eBaseEntity.id = e.Entity.id;
            }
            else
            {
                var e = context.BaseUsers.Update(eBaseEntity);
                await context.SaveChangesAsync();

                eBaseEntity.id = e.Entity.id;
            }
            SBaseAddresses.SaveClientAddresses(eBaseEntity.id, eBaseEntity.addressList);
            return(eBaseEntity.id);
        }
        static public async Task <string> Save(ECompanyWorkTimes eWorkTime)
        {
            try {
                using var context = new SMySQLContext();
                if (string.IsNullOrEmpty(eWorkTime.id))
                {
                    eWorkTime.id = Guid.NewGuid().ToString();
                    var e = await context.CompanyWorkTimes.AddAsync(eWorkTime);

                    await context.SaveChangesAsync();

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

                    return(e.Entity.id);
                }
            } catch (DbUpdateException e) {
                Console.WriteLine(e.ToString());
                throw;
            }
        }
        static public async Task <string> Save(ECompany eCompany)
        {
            if (eCompany.eCompanyConfig != null)
            {
                eCompany.config = JsonConvert.SerializeObject(eCompany.eCompanyConfig, Formatting.Indented);
            }
            using var context            = new SMySQLContext();
            eCompany.modificationDateUTC = DateTime.UtcNow;
            if (string.IsNullOrEmpty(eCompany.id))
            {
                eCompany.id = Guid.NewGuid().ToString();
                eCompany.creationDateUTC = DateTime.UtcNow;
                var e = await context.Companies.AddAsync(eCompany);

                await context.SaveChangesAsync();

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

                return(e.Entity.id);
            }
        }
        //=====================================================GETS ABOVE=====================================================

        #region Save
        static public async Task <string> Save(EDeliveryOrder eOrder)
        {
            try {
                eOrder.modificationDateUTC = DateTime.UtcNow;
                using var context          = new SMySQLContext();
                if (string.IsNullOrEmpty(eOrder.id))
                {
                    eOrder.id = Guid.NewGuid().ToString();
                    eOrder.creationDateUTC = eOrder.modificationDateUTC = DateTime.UtcNow;
                    var e = await context.DeliveryOrders.AddAsync(eOrder);

                    await context.SaveChangesAsync();

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

                    return(e.Entity.id);
                }
            } catch (DbUpdateException e) {
                Console.WriteLine(e.ToString());
                throw;
            }
        }
        public async Task <IActionResult> Save([FromBody] EServerConfig eConfig)
        {
            using (var context = new SMySQLContext()) {
                var e = context.Update(eConfig);
                await context.SaveChangesAsync();

                return(Ok(e.Entity.id));
            }
        }
示例#8
0
        //=====================================================GETS ABOVE=====================================================

        #region AddAsync
        public async Task <string> AddAsync(ESearch eSearch)
        {
            eSearch.CreationDateUTC = DateTime.UtcNow;
            eSearch.Id        = Guid.NewGuid().ToString();
            using var context = new SMySQLContext();
            var e = await context.Searches.AddAsync(eSearch);

            await context.SaveChangesAsync();

            return(e.Entity.Id);
        }
        //=====================================================GETS ABOVE=====================================================

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

                await context.SaveChangesAsync();

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

                return(e.Entity.id);
            }
        }
示例#10
0
        public async Task <IActionResult> Save([FromBody] ECompanyAdminUser eUser)
        {
            using (var context = new SMySQLContext()) {
                if (string.IsNullOrEmpty(eUser.id))
                {
                    var e = await context.CompanyUsers.AddAsync(eUser);

                    await context.SaveChangesAsync();

                    return(Ok(e.Entity.id));
                }
                else
                {
                    var e = context.CompanyUsers.Update(eUser);
                    await context.SaveChangesAsync();

                    return(Ok(e.Entity.id));
                }
            }
        }
示例#11
0
        public async Task <Int64> SaveAsync(EUser eUser)
        {
            eUser.ModificationDateUTC = DateTime.UtcNow;
            await using var context   = new SMySQLContext();
            if (eUser.Id < 1)
            {
                eUser.CreationDateUTC = eUser.ModificationDateUTC = DateTime.UtcNow;
                var e = await context.Users.AddAsync(eUser);

                await context.SaveChangesAsync();

                return(e.Entity.Id);
            }
            else
            {
                var e = context.Users.Update(eUser);
                await context.SaveChangesAsync();

                return(e.Entity.Id);
            }
        }
示例#12
0
        public async Task <string> SaveAsync(ECompanyAdminUser eCompanyAdminUser)
        {
            eCompanyAdminUser.ModificationDateUTC = DateTime.UtcNow;
            using var context = new SMySQLContext();
            if (string.IsNullOrEmpty(eCompanyAdminUser.Id))
            {
                eCompanyAdminUser.Id = Guid.NewGuid().ToString();
                eCompanyAdminUser.CreationDateUTC = DateTime.UtcNow;
                var e = await context.CompanyAdminUsers.AddAsync(eCompanyAdminUser);

                await context.SaveChangesAsync();

                return(e.Entity.Id);
            }
            else
            {
                var e = context.CompanyAdminUsers.Update(eCompanyAdminUser);
                await context.SaveChangesAsync();

                return(e.Entity.Id);
            }
        }
示例#13
0
        //=====================================================GETS ABOVE=====================================================

        #region SaveAsync
        public async Task <string> SaveAsync(EProduct eProduct)
        {
            eProduct.ModificationDateUTC = DateTime.UtcNow;
            using var context            = new SMySQLContext();
            if (string.IsNullOrEmpty(eProduct.Id))
            {
                eProduct.Id = Guid.NewGuid().ToString();
                eProduct.CreationDateUTC = DateTime.UtcNow;
                var e = await context.Products.AddAsync(eProduct);

                await context.SaveChangesAsync();

                return(e.Entity.Id);
            }
            else
            {
                var e = context.Products.Update(eProduct);
                await context.SaveChangesAsync();

                return(e.Entity.Id);
            }
        }
示例#14
0
        public async Task <bool> RemoveAsync(string id)
        {
            using var context = new SMySQLContext();
            var e = context.CompanyAdminUsers.SingleOrDefault(x => x.Id == id);

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

            return(true);
        }
        static public async Task <bool> Remove(string id)
        {
            using var context = new SMySQLContext();
            EBaseEntity eBaseEntity = context.BaseUsers.SingleOrDefault(x => x.id == id);

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

            return(true);
        }
示例#16
0
        //=====================================================GETS ABOVE=====================================================

        #region Save
        static public async Task <string> Save(ECompanyProposal eProposal)
        {
            eProposal.modificationDateUTC = DateTime.UtcNow;
            using (var context = new SMySQLContext()) {
                if (string.IsNullOrEmpty(eProposal.id))
                {
                    eProposal.id = Guid.NewGuid().ToString();
                    eProposal.creationDateUTC = DateTime.UtcNow;
                    var e = await context.CompanyProposals.AddAsync(eProposal);

                    await context.SaveChangesAsync();

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

                    return(e.Entity.id);
                }
            }
        }
        //=====================================================GETS ABOVE=====================================================

        #region Save
        static public async Task <string> Save(EBaseEntity eBaseEntity)
        {
            eBaseEntity.modificationDateUTC = DateTime.UtcNow;
            using (var context = new SMySQLContext()) {
                if (string.IsNullOrEmpty(eBaseEntity.id))
                {
                    eBaseEntity.id = Guid.NewGuid().ToString();
                    eBaseEntity.creationDateUTC = DateTime.UtcNow;
                    var e = await context.BaseUsers.AddAsync(eBaseEntity);

                    await context.SaveChangesAsync();

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

                    return(e.Entity.id);
                }
            }
        }
示例#18
0
        static public async Task <bool> Remove(string id)
        {
            using (var context = new SMySQLContext()) {
                ELogisticsDriverIncident eCompanyProposal = context.LogisticsDriverIncidents.SingleOrDefault(x => x.id == id);
                if (eCompanyProposal == null)
                {
                    return(false);
                }
                context.Remove(eCompanyProposal);
                await context.SaveChangesAsync();

                return(true);
            }
        }
        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);
            }
        }
示例#20
0
        public async Task <IActionResult> Remove(string id)
        {
            using (var context = new SMySQLContext()) {
                ECompany eCompany = context.Companies.SingleOrDefault(x => x.id == id);
                if (eCompany == null)
                {
                    return(Ok(false));
                }
                context.Remove(eCompany);
                await context.SaveChangesAsync();

                return(Ok(true));
            }
        }
        static public async Task <bool> Remove(string id)
        {
            using var context = new SMySQLContext();
            EDeliveryOrder eOrder = context.DeliveryOrders.SingleOrDefault(x => x.id == id);

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

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

        #region AddCompanyAsync
        public async Task <EUserCompany> AddCompanyAsync(EUserCompany e)
        {
            using var context = new SMySQLContext();

            //var ecompany = context.Companies.Where(x => x.Name == e.CompanyName).FirstOrDefault();
            //e.CompanyId = ecompany.Id;

            e.ModificationDateUTC = DateTime.UtcNow;
            e.CreationDateUTC     = DateTime.UtcNow;
            var result = await context.UserCompanies.AddAsync(e);

            await context.SaveChangesAsync();

            return(result.Entity);
        }