Esempio n. 1
0
        private void Login()
        {
            var user = MainContext.GetEntities <User>().FirstOrDefault(a => a.Id == UserId && a.Password == Password);

            if (user != null && UserId != "Any")
            {
                var Auth    = new Authorize();
                var machine = MainContext.GetEntities <Machine>().FirstOrDefault(a => a.ProcessorId == Machine.GetProcessorId() && a.Name == Environment.MachineName);
                if (machine == null)
                {
                    machine             = new Machine();
                    machine.ProcessorId = Machine.GetProcessorId();
                    machine.Name        = Environment.MachineName;
                }
                Auth.Machine = machine;
                Auth.User    = user;
                MainContext.AddEntity(Auth);
                MainContext.SaveChanges();
                Helper.OpenWindow <MainViewModel>();
                TryClose();
            }
            else
            {
                Model.Helpers.Message.ShowErrorMsg("Incorrect login or password");
            }
        }
Esempio n. 2
0
        private void AddPeriodCmd()
        {
            var newPeriod = new Period();

            MainContext.AddEntity(newPeriod);
            Periods.Add(newPeriod);
            SelectedPeriod = newPeriod;
        }
Esempio n. 3
0
 private void AddCommentCmd()
 {
     if (Task != null && TextComment != "")
     {
         Comment comment = new Comment();
         comment.Date = DateTime.Now;
         comment.Task = Task;
         comment.User = MainContext.GetEntities <User>().Single(a => a.Id == User.Id);
         comment.Text = TextComment;
         MainContext.AddEntity(comment);
         MainContext.SaveChanges();
         TextComment = "";
     }
 }
Esempio n. 4
0
 private void AddCmd()
 {
     if (!MainContext.GetEntities <User>().Any(a => a.Id == UserId))
     {
         User user = new User
         {
             Id         = UserId,
             Password   = Password,
             Possession = Possession
         };
         MainContext.AddEntity(user);
         MainContext.SaveChanges();
         Message.ShowComMsg("You added new User");
         TryClose();
     }
 }
Esempio n. 5
0
 private void AddProjectCmd()
 {
     try
     {
         var newProject = new Project();
         MainContext.AddEntity(newProject);
         Projects.Add(newProject);
         SelectedProject = newProject;
         MainContext.SaveChanges();
     }
     catch (Exception ex)
     {
         //  string msg = Helper.GetMessage(ex);
         // Message.ShowErrorMsg("Name must be unique!\n"+msg);
     }
 }
Esempio n. 6
0
 private void AddTaskCmd()
 {
     try
     {
         var newTask = new DTask();
         MainContext.AddEntity(newTask);
         Tasks.Add(newTask);
         SelectedTask = newTask;
         SelectedTask.Assignee = User;
         SelectedTask.CreatedBy = User;
         SelectedTask.Validator = User;
         SelectedTask.Period = CurrentPeriod;
         SaveCmd();
         NotifyOfPropertyChange(nameof(SelectedTask));
     }
     catch (Exception ex)
     {
         string msg = Helper.GetMessage(ex);
         // Message.ShowErrorMsg("This Task is already exists! Title must be unique!\n" + msg);
     }
 }