Пример #1
0
        public ActionResult CreatePiece(PieceViewModel pieces)
        {
            using (DataStoreContext db = new DataStoreContext())
            {
                if (ModelState.IsValid)
                {
                    var matchingArtWork = db.ArtWork.First(a => a.Title == pieces.Title).ArtWorkId;

                    if (matchingArtWork > 0)
                    {
                        IndividualPiece piece = new IndividualPiece
                        {
                            ArtWorkId     = matchingArtWork,
                            Image         = pieces.Image,
                            Price         = pieces.AskingPrice,
                            Cost          = pieces.Cost,
                            Sold          = pieces.Sold,
                            EditionNumber = pieces.EditionNumber,
                            Location      = pieces.Location,
                            InvoiceId     = null
                        };
                        db.IndividualPiece.Add(piece);
                        db.SaveChanges();
                        return(RedirectToAction("Index"));
                    }
                    else
                    {
                        ViewBag.Title = "Our system currently only supports adding new prints of existing art.";
                    }
                }

                return(View(pieces));
            }
        }
        private void DeleteCommand_Click(object sender, RoutedEventArgs e)
        {
            if (CommandTable.SelectedItem == null)
            {
                return;
            }
            TransmitCommand tc = new TransmitCommand();

            tc = CommandTable.SelectedItem as TransmitCommand;
            if (tc == null)
            {
                return;
            }
            int temp = tc.ID;

            Test.Text = temp.ToString();
            using (var commandContext = new DataStoreContext())
            {
                commandContext.TransmitCommands.Load();
                var tempContext = commandContext.TransmitCommands.Local;
                tempContext.Remove(commandContext.TransmitCommands.Find(temp));
                commandContext.SaveChanges();
                CommandTable.DataContext = commandContext.TransmitCommands.Local;
            }
        }
Пример #3
0
        public ActionResult EditAgent(AgentViewModel agents)
        {
            using (DataStoreContext db = new DataStoreContext())
            {
                var agent = db.Agent.Find(agents.AgentId);
                if (ModelState.IsValid)
                {
                    agent.Name     = agents.Name;
                    agent.Location = agents.Location;
                    agent.Active   = agents.Active;
                    db.SaveChanges();
                    return(RedirectToAction("Agents"));
                }

                return(View(agents));
            }
        }
Пример #4
0
        public ActionResult Edit(EmployeeDepartmentDetailViewModel employeeDetails)
        {
            using (DataStoreContext _context = new DataStoreContext())
            {
                var employee   = _context.Employee.Find(employeeDetails.EmployeeId);
                var department = _context.Department;
                if (ModelState.IsValid)
                {
                    employee.Name = employeeDetails.Name;

                    _context.SaveChanges();
                    return(RedirectToAction("Index"));
                }

                return(View(employeeDetails));
            }
        }
Пример #5
0
        // DELETE
        public ActionResult DeletePiece(int IndividualPieceId)
        {
            if (IndividualPieceId != 0)
            {
                using (DataStoreContext db = new DataStoreContext())
                {
                    IndividualPiece piece = db.IndividualPiece.Find(IndividualPieceId);

                    db.IndividualPiece.Remove(piece);
                    db.SaveChanges();
                }
            }
            else
            {
                ViewBag.Title = "There was a problem";
            }
            return(RedirectToAction("Index"));
        }
Пример #6
0
        public ActionResult EditPiece(PieceViewModel pieces)
        {
            using (DataStoreContext db = new DataStoreContext())
            {
                var piece = db.IndividualPiece.Find(pieces.IndividualPieceId);

                if (ModelState.IsValid)
                {
                    piece.Cost  = pieces.Cost;
                    piece.Price = pieces.AskingPrice;
                    piece.Sold  = pieces.Sold;
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }

                return(View(pieces));
            }
        }
Пример #7
0
 public ActionResult Create(EmployeeDepartmentDetailViewModel employeeDetails)
 {
     using (DataStoreContext _context = new DataStoreContext())
     {
         if (ModelState.IsValid)
         {
             Employee employee = new Employee
             {
                 Name         = employeeDetails.Name,
                 DepartmentId = employeeDetails.DepartmentId
             };
             _context.Employee.Add(employee);
             _context.SaveChanges();
             return(RedirectToAction("Index"));
         }
         return(View(employeeDetails));
     }
 }
Пример #8
0
        public ActionResult Delete(int employeeId)
        {
            if (employeeId != 0)
            {
                using (DataStoreContext _context = new DataStoreContext())
                {
                    Employee employee = _context.Employee.Find(employeeId);

                    _context.Employee.Remove(employee);
                    _context.SaveChanges();
                }
            }
            else
            {
                ViewBag.Title = "There was a problem";
            }
            return(RedirectToAction("Index"));
        }
Пример #9
0
        /// <summary>
        /// Starts the creation of a payment for our list of open orders by creating a "Pending"-payment.
        /// Later pages may move this state to an end state (e.g. Paid, or Cancelled).
        /// </summary>
        /// <returns></returns>
        public async Task <IActionResult> OnGetPay()
        {
            //get orders which aren't paid yet
            var myOrders = await PopulateMyListOfOrders();

            AssignOrders(myOrders);

            if (OrdersWithoutPayment.Count == 0)
            {
                return(Page());
            }

            decimal amountToPay = AmountToPay;

            //create a payment and assign to them
            var newPayment = new Payment()
            {
                Amount    = amountToPay,
                Method    = PaymentMethod.WireTransfer,
                State     = PaymentState.BeingProcessed, //Can be confirmed later
                Reference = _referenceFactory.Create().AsPrintReference()
            };

            _context.Payment.Add(newPayment);

            //store the orders with their payment;
            foreach (var order in OrdersWithoutPayment)
            {
                var orderPaymentLink = new OrderPayments()
                {
                    OrderId   = order.OrderId,
                    PaymentId = newPayment.ID
                };
                _context.OrderPayment.Add(orderPaymentLink);
            }

            _context.SaveChanges();

            //redirect to payment page
            return(RedirectToPage("/Payments/Wiretransfer/Pay", new
            {
                paymentId = newPayment.ID
            }));
        }
Пример #10
0
        public async Task <IActionResult> OnPostAsync(string id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            var payment = await _context.Payment.FindAsync(id);

            if (payment == null)
            {
                return(NotFound());
            }

            payment.State = PaymentState.Paid;
            _context.Payment.Update(payment);
            _context.SaveChanges();

            return(RedirectToPage("./Index"));
        }
Пример #11
0
        public ActionResult CreateAgent(AgentViewModel agents)
        {
            using (DataStoreContext db = new DataStoreContext())
            {
                if (ModelState.IsValid)
                {
                    Agent agent = new Agent
                    {
                        Name        = agents.Name,
                        Location    = agents.Location,
                        Address     = agents.Address,
                        PhoneNumber = agents.PhoneNumber,
                        Active      = agents.Active
                    };
                    db.Agent.Add(agent);
                    db.SaveChanges();
                    return(RedirectToAction("Agents"));
                }

                return(View(agents));
            }
        }
Пример #12
0
 [HttpPost] //must be here for page to work, sends data on submit button click
 public ActionResult CreateArtWork(ArtWorkViewModel artworkDetails)
 {
     using (DataStoreContext db = new DataStoreContext())
     {
         if (ModelState.IsValid)
         {
             ArtWork artwork = new ArtWork
             {
                 Artist = artworkDetails.Artist,
                 Title  = artworkDetails.Title,
                 YearOriginalCreated = artworkDetails.YearOriginalCreated,
                 Medium            = artworkDetails.Medium,
                 Dimensions        = artworkDetails.Dimensions,
                 NumberMade        = artworkDetails.NumberMade,
                 NumberInInventory = artworkDetails.NumberInInventory,
                 NumberSold        = artworkDetails.NumberSold,
             };
             db.ArtWork.Add(artwork); //saves info to the context
             db.SaveChanges();        //saves info to the databse
             return(RedirectToAction("Index"));
         }
     }
     return(View(artworkDetails));
 }
Пример #13
0
 public void Add(SalesPersonWrapper seller)
 {
     _storage.Seller.Add(seller);
     _storage.SaveChanges();
 }
        private void AddCommand_Click(object sender, RoutedEventArgs e)
        {
            if (StartSelect.Text == string.Empty || TargetSelect.Text == string.Empty || CarSelect.Text == string.Empty || RailSelect.Text == string.Empty || PrioritySelect.Text == string.Empty)
            {
                MessageBox.Show("Please select start station!!!");
                return;
            }
            string carID  = CarSelect.Text.Trim();
            string railID = RailSelect.Text.Trim();
            string spa    = StartSelect.Text.Trim();
            string sla    = null;
            string tpa    = TargetSelect.Text.Trim();
            string tla    = null;
            int    priority;

            Int32.TryParse(PrioritySelect.Text.Trim(), out priority);
            foreach (CommonStationControl csc in myStationStore)
            {
                if (csc == null)
                {
                    MessageBox.Show("Please select 0~~24 Station!!!");
                    return;
                }
                if (csc.StationText == StartSelect.Text.Substring(7).Trim())
                {
                    sla = csc.Margin.Left.ToString() + "," + csc.Margin.Top.ToString();
                }
            }

            foreach (CommonStationControl csc in myStationStore)
            {
                if (csc == null)
                {
                    MessageBox.Show("Please select 0~~24 Station!!!");
                    return;
                }
                if (csc.StationText == TargetSelect.Text.Substring(7).Trim())
                {
                    tla = csc.Margin.Left.ToString() + "," + csc.Margin.Top.ToString();
                }
            }
            using (var commandContext = new DataStoreContext())
            {
                commandContext.TransmitCommands.Load();
                commandContext.TransmitCommands.Add(new TransmitCommand
                {
                    Number = Guid.NewGuid().ToString(),
                    CarID  = carID,
                    RailID = railID,
                    StartPhysicalAddress  = spa,
                    StartLogicalAddress   = sla,
                    TargetPhysicalAddress = tpa,
                    TargetLogicalAddress  = tla,
                    Priority     = priority,
                    CreateTime   = DateTime.Now,
                    CompleteTime = DateTime.Now,
                    IsComplete   = false
                });
                commandContext.SaveChanges();
                CommandTable.DataContext = commandContext.TransmitCommands.Local;
            }
        }
Пример #15
0
 public void Add(Order order)
 {
     _context.Order.Add(order);
     _context.SaveChanges();
 }
Пример #16
0
 public void Add(Customer buyer)
 {
     _storage.Buyer.Add(buyer);
     _storage.SaveChanges();
 }