示例#1
0
        static public ELogisticsDriverIncident GetByID(string id)
        {
            using var context = new SMySQLContext();
            ELogisticsDriverIncident eIncident = context.LogisticsDriverIncidents.SingleOrDefault(x => x.id == id);

            return(eIncident);
        }
示例#2
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;
            }
        }
示例#3
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);
            }
        }
        public async Task <IActionResult> Save([FromBody] ELogisticsDriverIncident eIncident)
        {
            var result = await SLogisticsDriversIncidents.Save(eIncident);

            return(Ok(result));
        }