Пример #1
0
 public ActionResult AddCustomer(UserCustomer newAccount)
 {
     if (ModelState.IsValid)
     {
         var entity = new Users()
         {
             Email = newAccount.newUser.Email, Password = newAccount.newUser.Password, PasswordConf = newAccount.newUser.PasswordConf, RoleID = 1
         };
         db.users.Add(entity);
         db.SaveChanges();
         int newUserID = (int)entity.UserID;
         var entity2   = new Customers()
         {
             Address     = newAccount.newCustomer.Address,
             City        = newAccount.newCustomer.City,
             CompanyName = newAccount.newCustomer.CompanyName,
             Email       = newAccount.newUser.Email,
             Phone       = newAccount.newCustomer.Phone,
             RepID       = newAccount.newCustomer.RepID,
             SMS         = newAccount.newCustomer.SMS,
             Zip         = newAccount.newCustomer.Zip,
             UserID      = newUserID
         };
         db.customers.Add(entity2);
         db.SaveChanges();
         return(RedirectToAction("Index", "Home"));
     }
     else
     {
         return(View(newAccount));
     }
 }
Пример #2
0
 public ActionResult Edit(Samples updatedSample)
 {
     updatedSample.AssayStatus = "Received";
     using (db)
     {
         db.samples.Attach(updatedSample);
         db.Entry(updatedSample).Property(x => x.ScheduleCompletion).IsModified = true;
         db.Entry(updatedSample).Property(x => x.DateArrived).IsModified        = true;
         db.Entry(updatedSample).Property(x => x.ActualWeight).IsModified       = true;
         db.Entry(updatedSample).Property(x => x.MTD).IsModified         = true;
         db.Entry(updatedSample).Property(x => x.AssayStatus).IsModified = true;
         db.SaveChanges();
     }
     return(RedirectToAction("SentOrders"));
 }
Пример #3
0
        public ActionResult QuoteDone(int id)
        {
            var item = db.quotes.Where(x => x.QuoteID == id).First();

            item.QuoteStatusID = 3;
            using (db)
            {
                db.quotes.Attach(item);
                db.Entry(item).Property(x => x.QuoteStatusID).IsModified = true;
                db.SaveChanges();
            }
            return(RedirectToAction("ListQuotes"));
        }
Пример #4
0
        public ActionResult ImportData()
        {
            if (currentOrder.listCompound.Count == 1)
            {
                var entity = new Orders()
                {
                    CustID = currentUser.CustID
                };
                db.orders.Add(entity);
                db.SaveChanges();
                currentOrderID = (int)entity.OrderID;
            }
            var entity2 = new Customer_Compound()
            {
                CompoundName    = currentOrder.listCompound.ElementAt(currentIndex).compoundName,
                CompoundFormula = currentOrder.listCompound.ElementAt(currentIndex).compoundFormula,
                TotalSamples    = currentOrder.listCompound.ElementAt(currentIndex).totalSamples
            };

            db.customer_compound.Add(entity2);
            db.SaveChanges();
            int newLTNumber = (int)entity2.LTNumber;
            var entity3     = new Order_LabTests()
            {
                OrderID  = currentOrderID,
                LTNumber = newLTNumber
            };

            db.order_labtests.Add(entity3);
            db.SaveChanges();
            for (int i = 0; i < sampleIndexMax; ++i)
            {
                var entity4 = new Samples()
                {
                    SequenceCode    = i + 1,
                    LTNumber        = newLTNumber,
                    CatalogID       = currentOrder.listCompound.ElementAt(currentIndex).listSamples.ElementAt(i).catalogID,
                    MolecularMass   = currentOrder.listCompound.ElementAt(currentIndex).listSamples.ElementAt(i).molecularMass,
                    ActualWeight    = currentOrder.listCompound.ElementAt(currentIndex).listSamples.ElementAt(i).actualWeight,
                    PriorityLevelID = currentOrder.listCompound.ElementAt(currentIndex).listSamples.ElementAt(i).priorityLevelID,
                    AssayStatus     = "Sent",
                };
                if (currentOrder.listCompound.ElementAt(currentIndex).listSamples.ElementAt(i).MTD)
                {
                    entity4.IsAnimal = true;
                }
                else
                {
                    entity4.IsAnimal = false;
                }
                db.samples.Add(entity4);
                db.SaveChanges();
            }
            return(RedirectToAction("AddAnotherCompound"));
        }