示例#1
0
        public void Save(LeJourDBContext context, JsonElement body)
        {
            try
            {
                var wfModel = JsonSerializer.Deserialize <WeddingFavorites>(body.ToString());

                var wf = new TbWeddingFavorites
                {
                    idWedding = wfModel.idWedding,
                    idVendor  = wfModel.idVendor,
                };


                using (context)
                {
                    if (context.TbWeddingFavorites.Where(u => u.idWedding == wf.idWedding).Any())
                    {
                        context.TbWeddingFavorites.Update(wf);

                        if (context.TbWeddingFavorites.Where(a => a.idVendor == wf.idVendor).Any())
                        {
                            context.TbWeddingFavorites.Update(wf);
                        }
                        else
                        {
                            context.TbWeddingFavorites.Add(wf);
                        }
                    }
                    else
                    {
                        context.TbWeddingFavorites.Add(wf);
                    }

                    context.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                //Log exception
                throw;
            }
        }
示例#2
0
        public void Save(LeJourDBContext context, JsonElement body)
        {
            try
            {
                var userModel = JsonSerializer.Deserialize <User>(body.ToString());

                var user = new TbUser
                {
                    idUser    = userModel.idUser,
                    dtCreated = userModel.dtCreated,
                };


                using (context)
                {
                    if (context.TbUser.Where(u => u.idUser == user.idUser).Any())
                    {
                        context.TbUser.Update(user);

                        if (context.TbUser.Where(a => a.idUser == user.idUser).Any())
                        {
                            context.TbUser.Update(user);
                        }
                        else
                        {
                            context.TbUser.Add(user);
                        }
                    }
                    else
                    {
                        context.TbUser.Add(user);
                    }

                    context.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                //Log exception
                throw;
            }
        }
示例#3
0
        public void Save(LeJourDBContext context, JsonElement body)
        {
            try
            {
                var weddingModel = JsonSerializer.Deserialize <Wedding>(body.ToString());

                var wedding = new TbWedding
                {
                    idWedding = weddingModel.idWedding,
                    idUser    = weddingModel.idUser,
                    vlBudget  = weddingModel.vlBudget,
                    dtWedding = weddingModel.dtWedding,
                    nmGuests  = weddingModel.nmGuests,
                    dsStyle   = weddingModel.dsStyle
                };


                using (context)
                {
                    if (context.TbWedding.Where(u => u.idWedding == wedding.idWedding).Any())
                    {
                        context.TbWedding.Update(wedding);

                        if (context.TbWedding.Where(a => a.idUser == wedding.idUser).Any())
                        {
                            context.TbWedding.Update(wedding);
                        }

                        if (context.TbWedding.Where(a => a.vlBudget == wedding.vlBudget).Any())
                        {
                            context.TbWedding.Update(wedding);
                        }

                        if (context.TbWedding.Where(a => a.nmGuests == wedding.nmGuests).Any())
                        {
                            context.TbWedding.Update(wedding);
                        }

                        if (context.TbWedding.Where(a => a.dsStyle == wedding.dsStyle).Any())
                        {
                            context.TbWedding.Update(wedding);
                        }
                        else
                        {
                            context.TbWedding.Add(wedding);
                        }
                    }
                    else
                    {
                        context.TbWedding.Add(wedding);
                    }

                    context.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                //Log exception
                throw;
            }
        }
示例#4
0
        public void Save(LeJourDBContext context, JsonElement body)
        {
            try
            {
                var invoiceModel = JsonSerializer.Deserialize <Invoice>(body.ToString());

                var invoice = new TbInvoice
                {
                    idInvoice        = invoiceModel.idInvoice,
                    idWedding        = invoiceModel.idWedding,
                    idVendor         = invoiceModel.idVendor,
                    vlAmount         = invoiceModel.vlAmount,
                    vlAmountVendor   = invoiceModel.vlAmountVendor,
                    dtCreated        = invoiceModel.dtCreated,
                    dsAccepted       = invoiceModel.dsAccepted,
                    dsCategoryVendor = invoiceModel.dsCategoryVendor
                };


                using (context)
                {
                    if (context.TbInvoice.Where(u => u.idInvoice == invoice.idInvoice).Any())
                    {
                        context.TbInvoice.Update(invoice);

                        if (context.TbInvoice.Where(a => a.idWedding == invoice.idWedding).Any())
                        {
                            context.TbInvoice.Update(invoice);
                        }

                        if (context.TbInvoice.Where(a => a.idVendor == invoice.idVendor).Any())
                        {
                            context.TbInvoice.Update(invoice);
                        }

                        if (context.TbInvoice.Where(a => a.vlAmount == invoice.vlAmount).Any())
                        {
                            context.TbInvoice.Update(invoice);
                        }

                        if (context.TbInvoice.Where(a => a.vlAmountVendor == invoice.vlAmountVendor).Any())
                        {
                            context.TbInvoice.Update(invoice);
                        }

                        if (context.TbInvoice.Where(a => a.dtCreated == invoice.dtCreated).Any())
                        {
                            context.TbInvoice.Update(invoice);
                        }

                        if (context.TbInvoice.Where(a => a.dsAccepted == invoice.dsAccepted).Any())
                        {
                            context.TbInvoice.Update(invoice);
                        }

                        if (context.TbInvoice.Where(a => a.dsCategoryVendor == invoice.dsCategoryVendor).Any())
                        {
                            context.TbInvoice.Update(invoice);
                        }

                        context.TbInvoice.Add(invoice);
                    }
                    else
                    {
                        context.TbInvoice.Add(invoice);
                    }

                    context.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                //Log exception
                throw;
            }
        }
示例#5
0
        public void Save(LeJourDBContext context, JsonElement body)
        {
            try
            {
                var appointmentModel = JsonSerializer.Deserialize <Appointment>(body.ToString());

                var appointment = new TbAppointment
                {
                    idAppointment    = appointmentModel.idAppointment,
                    idWedding        = appointmentModel.idWedding,
                    idVendor         = appointmentModel.idVendor,
                    idStatus         = appointmentModel.idStatus,
                    dsCategoryVendor = appointmentModel.dsCategoryVendor,
                    dtAppointment    = appointmentModel.dtAppointment
                };


                using (context)
                {
                    if (context.TbAppointment.Where(u => u.idAppointment == appointment.idAppointment).Any())
                    {
                        context.TbAppointment.Update(appointment);

                        if (context.TbAppointment.Where(a => a.idWedding == appointment.idWedding).Any())
                        {
                            context.TbAppointment.Update(appointment);
                        }

                        if (context.TbAppointment.Where(a => a.idVendor == appointment.idVendor).Any())
                        {
                            context.TbAppointment.Update(appointment);
                        }

                        if (context.TbAppointment.Where(a => a.idStatus == appointment.idStatus).Any())
                        {
                            context.TbAppointment.Update(appointment);
                        }

                        if (context.TbAppointment.Where(a => a.dsCategoryVendor == appointment.dsCategoryVendor).Any())
                        {
                            context.TbAppointment.Update(appointment);
                        }

                        if (context.TbAppointment.Where(a => a.dtAppointment == appointment.dtAppointment).Any())
                        {
                            context.TbAppointment.Update(appointment);
                        }
                        else
                        {
                            context.TbAppointment.Add(appointment);
                        }
                    }
                    else
                    {
                        context.TbAppointment.Add(appointment);
                    }

                    context.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                //Log exception
                throw;
            }
        }