示例#1
0
 public bool InsertItem(T item)
 {
     try
     {
         dbContext = new DbServiceProviderAppEntities();
         dbContext.Set <T>().Add(item);
         dbContext.SaveChanges();
     }
     catch (Exception e)
     {
         dbContext.Set <T>().Remove(item);
         return(false);
     }
     return(true);
 }
示例#2
0
        public bool LogIn(string username, string password)
        {
            SpaUser         NewUser = new SpaUser();
            Synchronisation Sync    = null;

            try
            {
                dbContext = new DbServiceProviderAppEntities();
                Sync      = new Synchronisation();
                NewUser   = Sync.LogIn(username, password);
            } catch (Exception e)                           //Bei fehlender Internetverbindung
            {
                return(false);
            }

            try
            {
                if (NewUser != null)
                {
                    LogOut();

                    dbContext.Set <spa_log_in>().Add(new spa_log_in {
                        user_id = NewUser.ServiceProviderId, last_login = DateTime.Now, is_logged_in = "Y"
                    });
                    dbContext.SaveChanges();
                    Sync.FullSync(NewUser.ServiceProviderId);

                    return(true);
                }
            } catch (Exception e)
            {
                throw e;
            }
            return(false);
        }
示例#3
0
        public void WriteLastSync(DateTime date)
        {
            dbContext = new DbServiceProviderAppEntities();

            dbContext.Set <spa_synctimes>().Add(new spa_synctimes {
                synctime = date
            });
            dbContext.SaveChanges();
        }
示例#4
0
        public void AddOrderItemReport(OrderItemReport_ NewReport)
        {
            dbContext = new DbServiceProviderAppEntities();

            //Holen der maximalen Order_item_report_id:
            Guid NextId = Guid.NewGuid();

            //Umwandeln des OrderItemReport in das DB-Objekt
            order_item_report DbNewReport = new order_item_report
            {
                createdat     = DateTime.Now,
                order_item_id = NewReport.OrderItemId,
                comment       = NewReport.Comment,
                Id            = NextId
            };

            dbContext.Set <order_item_report>().Add(DbNewReport);
            dbContext.SaveChanges();

            //Umwandeln der OrderItemReportAppendix in die DB-Objekte


            foreach (OrderItemReportAppendix oima in NewReport.Appendix)
            {
                Guid AppendixId = Guid.NewGuid();
                order_item_report_appendix DbOima = new order_item_report_appendix
                {
                    Id                   = AppendixId,
                    createdat            = DateTime.Now,
                    order_item_report_id = DbNewReport.Id,
                    appendix             = oima.Picture
                };

                dbContext.Set <order_item_report_appendix>().Add(DbOima);
            }

            UpdateDataBase();
            StartSynchronisation();
        }
示例#5
0
        public void AddOrderItemReport(OrderItemReport NewReport)
        {
            dbContext = new DbServiceProviderAppEntities();

            //Holen der maximalen Order_item_report_id:
            int NextId = (from oim in dbContext.order_item_report
                          select oim.Id).Max() + 1;

            //Umwandeln des OrderItemReport in das DB-Objekt
            order_item_report DbNewReport = new order_item_report
            {
                report_date   = NewReport.ReportDate,
                order_item_id = NewReport.OrderItemId,
                comment       = NewReport.Comment,
                Id            = NextId
            };

            dbContext.Set <order_item_report>().Add(DbNewReport);
            dbContext.SaveChanges();

            //Umwandeln der OrderItemReportAppendix in die DB-Objekte
            foreach (OrderItemReportAppendix oima in NewReport.Appendix)
            {
                order_item_report_appendix DbOima = new order_item_report_appendix
                {
                    order_item_report_id = DbNewReport.Id,
                    appendix             = oima.Picture
                };

                dbContext.Set <order_item_report_appendix>().Add(DbOima);
            }

            //schreiben der Änderung in die spa_changes Tabelle
            dbContext.Set <spa_changes>().Add(new spa_changes {
                order_id = NewReport.OrderItemId, change_date = DateTime.Now
            });
            UpdateDataBase();
        }
示例#6
0
        //Updated Änderungen am Detailitem
        public bool UpdateOrderItemData(DetailedClass DetailToUpdate)
        {
            dbContext = new DbServiceProviderAppEntities();
            //Auswerten des Order_item aus der DB
            order_item OriginalOrderItem = (from oi in dbContext.order_item
                                            where oi.Id == DetailToUpdate.OrderItemId
                                            select oi).FirstOrDefault(); //changed from first() to firstordefault()

            //order_item OriginalOrderItem = new order_item();
            if (OriginalOrderItem != null)
            {
                //Änderungsfähige Daten übernehmen
                OriginalOrderItem.addittional_cost         = DetailToUpdate.AddittionalCost;
                OriginalOrderItem.final_price              = DetailToUpdate.Finalprice;
                OriginalOrderItem.is_all_inclusive         = DetailToUpdate.IsAllInclusive;
                OriginalOrderItem.is_confirmed             = DetailToUpdate.IsConfirmed;
                OriginalOrderItem.is_finished              = DetailToUpdate.IsFinished;
                OriginalOrderItem.preferred_date_time      = DetailToUpdate.PreferedDate;
                OriginalOrderItem.service_provider_comment = DetailToUpdate.ServiceProviderComment;
                OriginalOrderItem.final_price_without_tax  = OriginalOrderItem.final_price / 1.2; //Falls der Final_Price geändert wurde
                OriginalOrderItem.final_price_with_tax     = OriginalOrderItem.final_price;       //Falls der Final_Price geändert wurde
                OriginalOrderItem.tax          = OriginalOrderItem.final_price_with_tax - OriginalOrderItem.final_price_without_tax;
                OriginalOrderItem.per_item_tax = OriginalOrderItem.tax / OriginalOrderItem.quantity;
                OriginalOrderItem.createdAt    = DateTime.Now;


                //schreiben der Änderung in die spa_changes Tabelle
                spa_changes chng = new spa_changes();
                chng.order_id    = OriginalOrderItem.Id;
                chng.change_date = DateTime.Now;

                dbContext.Set <spa_changes>().Add(chng);

                //Änderungen speichern

                dbContext.SaveChanges();

                return(true);
            }
            else
            {
                return(false);
            }
        }
示例#7
0
        public bool LogInAndCheckUserData(string username, string password)
        {
            dbContext = new DbServiceProviderAppEntities();

            var query = from ud in dbContext.service_provider_login
                        where ud.username == username && ud.password == password
                        select ud;

            List <service_provider_login> Userdata = query.ToList();

            //gibt True zurück, wenn es genau einen DB-Eintrag mit dem Usernamen und Passwort gibt.
            if (Userdata.Count() == 1)
            {
                dbContext.Set <spa_log_in>().Add(new spa_log_in {
                    user_id = Userdata[0].Id, last_login = DateTime.Now, is_logged_in = "Y"
                });
                dbContext.SaveChanges();
                return(true);
            }
            return(false);
        }