示例#1
0
        public bool ExchangeNew(string LoginSender, string LoginCreator, int IsOneWay)
        {
            using (ServerDatabaseContext databaseContext = new ServerDatabaseContext())
            {
                UserTable creator = databaseContext.UserTables.Where(u => u.Login == LoginCreator).FirstOrDefault();
                UserTable sender  = databaseContext.UserTables.Where(u => u.Login == LoginSender).FirstOrDefault();
                bool      isOne   = false;
                if (IsOneWay == 1)
                {
                    isOne = true;
                }
                DatabaseExchangeTable exchange = new DatabaseExchangeTable
                {
                    IsCreatorDone  = false,
                    IsOneWay       = isOne,
                    IsSenderAccept = null,
                    IsSenderDone   = false,
                    UserCreatorId  = creator.UserId,
                    UserSenderId   = sender.UserId
                };
                if (IsOneWay == 1)
                {
                    exchange.IsSenderDone = true;
                }

                databaseContext.DatabaseExchangeTables.Add(exchange);
                databaseContext.SaveChanges();
            }
            return(true);
        }
示例#2
0
 public bool ExchangeDone(int Id, int Doned)
 {
     using (ServerDatabaseContext databaseContext = new ServerDatabaseContext())
     {
         DatabaseExchangeTable exchange = databaseContext.DatabaseExchangeTables.Where(u => u.DatabaseExchangeId == Id).FirstOrDefault();
         if (Doned == 0)
         {
             exchange.IsSenderDone = false;
         }
         else
         {
             exchange.IsCreatorDone = true;
         }
         databaseContext.SaveChanges();
     }
     return(true);
 }
示例#3
0
 public bool ExchangeAccept(int Id, int Accepting)
 {
     using (ServerDatabaseContext databaseContext = new ServerDatabaseContext())
     {
         DatabaseExchangeTable exchange = databaseContext.DatabaseExchangeTables.Where(u => u.DatabaseExchangeId == Id).FirstOrDefault();
         if (Accepting == 0)
         {
             exchange.IsSenderAccept = false;
         }
         else
         {
             exchange.IsSenderAccept = true;
         }
         databaseContext.SaveChanges();
     }
     return(true);
 }