public void SpendPaddle()
        {
            var spendedPaddle = new SpendedPaddle
            {
                PaddleId                = SelectedReceivedPaddle.PaddleId,
                AddedDate               = SelectedReceivedPaddle.AddedDate,
                ActivityPerformed       = SelectedReceivedPaddle.ActivityPerformed,
                RepairDate              = RepairDate,
                Comments                = SelectedReceivedPaddle.Comments,
                IsOrders                = SelectedReceivedPaddle.IsOrders,
                DescriptionIntervention = DescriptionIntervention,
                ReceivingEmployee       = SelectedReceivedPaddle.ReceivingEmployee,
                SpendingEmployee        = String.Format("{0} {1}", EmployeeViewModel.SelectedEmployee.FirstName, EmployeeViewModel.SelectedEmployee.LastName)
            };

            context.CreateSpendedPaddle(spendedPaddle);
            context.UpdateLastPreventionDate(SelectedReceivedPaddle);

            if (SelectedReceivedPaddle != null)
            {
                context.DeleteReceivedPaddle(SelectedReceivedPaddle);
                ReceivedPaddles.Remove(SelectedReceivedPaddle);
                SelectedReceivedPaddle = null;
            }
            ConnectedSuccessfully = true;
        }
Example #2
0
        public void Spend(SpendedPaddle spendedPaddle)
        {
            Validator.RequireString(spendedPaddle.ActivityPerformed);
            Validator.RequireString(spendedPaddle.DescriptionIntervention);
            Validator.RequireString(spendedPaddle.ReceivingEmployee);
            Validator.RequireString(spendedPaddle.SpendingEmployee);

            context.SpendedPaddles.Add(spendedPaddle);
            context.SaveChanges();
        }
        public void Spend()
        {
            var spendedPaddle = new SpendedPaddle
            {
                PaddleId                = SelectedReceivedPaddle.PaddleId,
                ReceivedDate            = SelectedReceivedPaddle.ReceivedDate,
                ActivityPerformed       = SelectedReceivedPaddle.ActivityPerformed,
                RepairDate              = RepairDate,
                DescriptionIntervention = SelectedReceivedPaddle.DescriptionIntervention,
                ReceivingEmployee       = SelectedReceivedPaddle.ReceivingEmployee,
                SpendingEmployee        = String.Format("{0} {1}", EmployeeViewModel.SelectedEmployee.FirstName, EmployeeViewModel.SelectedEmployee.LastName)
            };

            context.Spend(spendedPaddle);
            context.SetLastPreventionDate(SelectedReceivedPaddle);

            if (SelectedReceivedPaddle != null)
            {
                context.Remove(SelectedReceivedPaddle);
                ReceivedPaddles.Remove(SelectedReceivedPaddle);
                SelectedReceivedPaddle = null;
            }
            ConnectedSuccessfully = true;
        }
 public void CreateSpendedPaddle(SpendedPaddle spendedPaddle)
 {
     context.SpendedPaddles.Add(spendedPaddle);
     context.SaveChanges();
 }