Exemplo n.º 1
0
        private async void SubmitButton_Click(object sender, RoutedEventArgs e)
        {
            var ticket   = new Ticket();
            var customer = new Customer();

            using (var Db = new HelpDeskDataContext())
            {
                try
                {
                    customer.Name       = CustomerList.Text;
                    ticket.DeviceType   = DeviceType.Text;
                    ticket.Customer     = customer;
                    ticket.SerialNumber = SerialNumberField.Text;
                    ticket.PartNumber   = PartNumberField.Text;
                    Db.Add(ticket);
                    Db.SaveChanges();
                    OutputTextBlock.Text = ticket.Id + " " + "Created.";
                }
                catch (Exception)
                {
                    var message = new MessageDialog("Error Ticket Not Created");
                    await message.ShowAsync();
                }
            }
            SubmitButton.IsEnabled = false;
            var send = new Send();
            await send.Send_Email(ticket);

            SubmitButton.IsEnabled = true;
            ClearField();
        }
Exemplo n.º 2
0
        public RegisteredEvent CreateReview(CreateEvent newRegistry)
        {
            using (HelpDeskDataContext helpDeskDataContext = new HelpDeskDataContext())
            {
                using (var transaction = helpDeskDataContext.Database.BeginTransaction())
                {
                    try
                    {
                        var eEvent = newRegistry.ToEntityReview();
                        helpDeskDataContext.Events.Add(eEvent);
                        helpDeskDataContext.SaveChanges();

                        var eRequest = helpDeskDataContext.Requests.Where(x => x.Id == eEvent.RequestId).First();
                        eRequest.State = 3;

                        helpDeskDataContext.Requests.Attach(eRequest);
                        helpDeskDataContext.Entry(eRequest).Property(x => x.State).IsModified = true;
                        helpDeskDataContext.SaveChanges();

                        transaction.Commit();

                        return(eEvent.ToDTO());
                    }
                    catch (Exception)
                    {
                        transaction.Rollback();
                        return(new RegisteredEvent());
                    }
                }
            }
        }
Exemplo n.º 3
0
 public List <RegisteredEventType> List()
 {
     using (HelpDeskDataContext helpDeskDataContext = new HelpDeskDataContext())
     {
         return(helpDeskDataContext.EventTypes.ToList().Select(x => x.ToDTO()).ToList());
     }
 }
Exemplo n.º 4
0
 public RegisteredUser ListUsersById(int userId)
 {
     using (HelpDeskDataContext helpDeskDataContext = new HelpDeskDataContext())
     {
         return(helpDeskDataContext.Users.Where(x => x.Id == userId).ToList().Select(x => x.ToDTO()).ToList().First());
     }
 }
Exemplo n.º 5
0
 public List <RegisteredRequestState> List()
 {
     using (HelpDeskDataContext helpDeskDataContext = new HelpDeskDataContext())
     {
         return(helpDeskDataContext.RequestStates.ToList().Select(x => x.ToDTO()).ToList());
     }
 }
Exemplo n.º 6
0
 public List <RegisteredUser> List()
 {
     using (HelpDeskDataContext helpDeskDataContext = new HelpDeskDataContext())
     {
         return(helpDeskDataContext.Users.ToList().Select(x => x.ToDTO()).ToList());
     }
 }
Exemplo n.º 7
0
 public List <RegisteredUser> Login(LoginRequest loginRequest)
 {
     using (HelpDeskDataContext helpDeskDataContext = new HelpDeskDataContext())
     {
         var list = helpDeskDataContext.Users.Where(x => x.UserName.Equals(loginRequest.User) && x.UserPassword.Equals(loginRequest.Pass)).ToList();
         return(list.Select(x => x.ToDTO()).ToList());
     }
 }
Exemplo n.º 8
0
 /// <summary>
 /// Initializes the singleton application object.  This is the first line of authored code
 /// executed, and as such is the logical equivalent of main() or WinMain().
 /// </summary>
 public App()
 {
     this.InitializeComponent();
     this.Suspending += OnSuspending;
     using (var Db = new HelpDeskDataContext())
     {
         Db.Database.Migrate();
     }
 }
Exemplo n.º 9
0
 public List <RegisteredEvent> ListEventsByRequest(int RequestId)
 {
     using (HelpDeskDataContext helpDeskDataContext = new HelpDeskDataContext())
     {
         return(helpDeskDataContext.Events
                .Include("User")
                .Include("EventType")
                .Where(x => x.RequestId == RequestId).ToList().Select(x => x.ToDTO()).ToList());
     }
 }
Exemplo n.º 10
0
 public RegisteredRequestFile CreateFile(CreateRequestFile createRequestFile)
 {
     using (HelpDeskDataContext helpDeskDataContext = new HelpDeskDataContext())
     {
         var newRequestFile = createRequestFile.ToEntity();
         helpDeskDataContext.Files.Add(newRequestFile);
         helpDeskDataContext.SaveChanges();
         return(newRequestFile.ToDTO());
     }
 }
Exemplo n.º 11
0
 public RegisteredRequest Create(CreateRequest newRegistry)
 {
     using (HelpDeskDataContext helpDeskDataContext = new HelpDeskDataContext())
     {
         var newRequest = newRegistry.ToEntity();
         helpDeskDataContext.Requests.Add(newRequest);
         helpDeskDataContext.SaveChanges();
         return(newRequest.ToDTO());
     }
 }
Exemplo n.º 12
0
 public RegisteredUser Create(CreateUser newRegistry)
 {
     using (HelpDeskDataContext helpDeskDataContext = new HelpDeskDataContext())
     {
         var eUser = newRegistry.ToEntity();
         helpDeskDataContext.Users.Add(eUser);
         helpDeskDataContext.SaveChanges();
         return(eUser.ToDTO());
     }
 }
Exemplo n.º 13
0
 public RegisteredEvent Create(CreateEvent newRegistry)
 {
     using (HelpDeskDataContext helpDeskDataContext = new HelpDeskDataContext())
     {
         var eEvent = newRegistry.ToEntity();
         helpDeskDataContext.Events.Add(eEvent);
         helpDeskDataContext.SaveChanges();
         return(eEvent.ToDTO());
     }
 }
Exemplo n.º 14
0
 public RegisteredModule Create(CreateModule newRegistry)
 {
     using (HelpDeskDataContext helpDeskDataContext = new HelpDeskDataContext())
     {
         var eModule = newRegistry.ToEntity();
         helpDeskDataContext.Modules.Add(eModule);
         helpDeskDataContext.SaveChanges();
         return(eModule.ToDTO());
     }
 }
Exemplo n.º 15
0
 public List <RegisteredRequest> List()
 {
     using (HelpDeskDataContext helpDeskDataContext = new HelpDeskDataContext())
     {
         return(helpDeskDataContext.Requests
                .Include(x => x.User)
                .Include(x => x.Module)
                .Include(x => x.RequestState)
                .Include(x => x.AttentionUser).ToList().Select(x => x.ToDTO()).ToList());
     }
 }
Exemplo n.º 16
0
 public RegisteredModule Update(UpdateModule updateRegistry)
 {
     using (HelpDeskDataContext helpDeskDataContext = new HelpDeskDataContext())
     {
         var module = updateRegistry.ToEntity();
         helpDeskDataContext.Modules.Attach(module);
         helpDeskDataContext.Entry(module).Property(x => x.Name).IsModified = true;
         helpDeskDataContext.SaveChanges();
         return(module.ToDTO());
     }
 }
Exemplo n.º 17
0
 public CustomerViewModel()
 {
     using (var Db = new HelpDeskDataContext())
     {
         var query = from c in Db.Customers
                     select c;
         foreach (var c in query)
         {
             CustList.Add(c);
             list = CustList;
         }
     }
 }
Exemplo n.º 18
0
 public List <RegisteredRequest> ListRequestsByStateAndUser(int UserId, int State)
 {
     using (HelpDeskDataContext helpDeskDataContext = new HelpDeskDataContext())
     {
         return(helpDeskDataContext.Requests
                .Include(x => x.User)
                .Include(x => x.Module)
                .Include(x => x.RequestState)
                .Include(x => x.AttentionUser).ToList()
                .Where(x => x.State == (State == 0 ? x.State : State) && x.UserId == UserId)
                .Select(x => x.ToDTO()).ToList());
     }
 }
Exemplo n.º 19
0
 public RegisteredRequest CloseRequest(UpdateRequest updateRequest)
 {
     using (HelpDeskDataContext helpDeskDataContext = new HelpDeskDataContext())
     {
         using (var transaction = helpDeskDataContext.Database.BeginTransaction())
         {
             var request = updateRequest.ToEntityClose();
             helpDeskDataContext.Requests.Attach(request);
             helpDeskDataContext.Entry(request).Property(x => x.State).IsModified            = true;
             helpDeskDataContext.Entry(request).Property(x => x.LastUpdateUserId).IsModified = true;
             helpDeskDataContext.SaveChanges();
             transaction.Commit();
             return(request.ToDTO());
         }
     }
 }
Exemplo n.º 20
0
 private async void SaveButton_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         using (var Db = new HelpDeskDataContext())
         {
             var customer = new Customer();
             customer.Name         = NameField.Text;
             customer.EmailAddress = EmailField.Text;
             Db.Add(customer);
             Db.SaveChanges();
             OutputTextBlock.Text = customer.Name + " " + "Created.";
             ClearField();
         }
     }
     catch (Exception)
     {
         var message = new MessageDialog("Unable to Create Ticket");
         await message.ShowAsync();
     }
 }