示例#1
0
 public void Remove(int id)
 {
     using (var dao = new TimeRepository())
     {
         dao.Remove(id);
     }
 }
示例#2
0
 private void Edit(Time time)
 {
     using (var dao = new TimeRepository())
     {
         dao.Edit(x => x.TimeId == time.TimeId, time);
     }
 }
示例#3
0
 public List <Time> List()
 {
     using (var dao = new TimeRepository())
     {
         return(dao.List().OrderBy(x => x.Nome).ToList());
     }
 }
示例#4
0
        static void Main(string[] args)
        {
            bool      KeepAppRunning = true;
            GuiDrawer GuiDrawer;

            GuiDrawer = new GuiDrawer(100, 15);

            while (KeepAppRunning)
            {
                Console.Clear();
                var items = new List <string>()
                {
                    "Value1", "Value2", "Value3"
                };
                GuiDrawer.DrawInterface(items);
                string userMessage = Console.ReadLine();

                if (userMessage == "quit")
                {
                    KeepAppRunning = false;
                }

                TimeRepository timeRepository = new TimeRepository("C:\\Users\\Barbe Rousse\\Documents\\_TimeSpentOnProjects\\Today.txt");
                timeRepository.Save(new TimeSpentOnProject()
                {
                    StartTime = DateTime.Now, EndTime = DateTime.Now, "FileWriter"
                });
示例#5
0
 private void Add(Time time)
 {
     using (var dao = new TimeRepository())
     {
         dao.Add(time);
     }
 }
示例#6
0
 public Time Find(int id)
 {
     using (var dao = new TimeRepository())
     {
         return(dao.Find(id));
     }
 }
示例#7
0
 public Admin()
 {
     Time.Data.TimeRepository repo = new TimeRepository();
     Clients   = repo.ListAllClients();
     Products  = repo.ListAllProducts();
     Proyects  = repo.ListAllProyects();
     Resources = repo.ListAllResources();
     Services  = repo.ListAllServices();
 }
示例#8
0
        public TimeViewModel()
        {
            timeRepo   = new TimeRepository();
            bookRepo   = new BookRepository();
            timeRules  = new ObservableCollection <TimeRule>();
            books      = new ObservableCollection <Book>();
            bookSearch = new ObservableCollection <Book>();

            LoadData();
        }
示例#9
0
        public ActionResult Details(int id)
        {
            //all object that we want to map with tryupdatemodel
            TaskDetailsVM model = new TaskDetailsVM();

            model.PagerComments = new Pager();
            model.PagerWorkLog  = new Pager();
            TryUpdateModel(model);

            //All repositories
            TasksRepository    taskRepo    = new TasksRepository();
            UsersRepository    userRepo    = new UsersRepository();
            TimeRepository     timeRepo    = new TimeRepository();
            CommentsRepository commentRepo = new CommentsRepository();

            //get the specific name that we show (inache kazano da ne e int kakto vika Bai Georgi)
            TaskEntity task            = (id <= 0) ? new TaskEntity() : taskRepo.GetById(id);
            UserEntity creatorUser     = null;
            UserEntity responsibleUser = null;

            if (id == 0)
            {
                creatorUser     = userRepo.GetById(AuthenticationManager.LoggedUser.Id);
                responsibleUser = userRepo.GetById(AuthenticationManager.LoggedUser.Id);
            }
            else
            {
                creatorUser     = userRepo.GetById(task.CreatorId);
                responsibleUser = userRepo.GetById(task.ResponsibleUsers);
            }

            //fill the model
            model.Id              = task.Id;
            model.CreatorName     = creatorUser.FirstName + " " + creatorUser.LastName;
            model.ResponsibleName = responsibleUser.FirstName + " " + responsibleUser.LastName;
            model.Content         = task.Content;
            model.Title           = task.Title;
            model.CreateTime      = task.CreateTime;
            UserEntity Users = userRepo.GetAll().FirstOrDefault(u => u.Id == task.CreatorId);

            //fill the model's list that give to the partialsViews
            model.CommentsList = commentRepo.GetAll(c => c.TaskId == model.Id, model.PagerComments.CurrentPage, model.PagerComments.PageSize).ToList();
            model.WorkLogList  = timeRepo.GetAll(w => w.TaskId == model.Id, model.PagerWorkLog.CurrentPage, model.PagerWorkLog.PageSize).ToList();

            //fill the pager with the specific data //Yanka beshe tuk :D :D :D kaza da go iztriq ama nqma da e

            string action     = this.ControllerContext.RouteData.Values["action"].ToString();
            string controller = this.ControllerContext.RouteData.Values["controller"].ToString();

            model.PagerComments = new Pager(commentRepo.GetAll().Count(c => c.TaskId == model.Id), model.PagerComments.CurrentPage, "PagerComments.", action, controller, model.PagerComments.PageSize);

            model.PagerWorkLog = new Pager(timeRepo.GetAll().Count(l => l.TaskId == model.Id), model.PagerWorkLog.CurrentPage, "PagerWorkLog.", action, controller, model.PagerWorkLog.PageSize);

            return(View(model));
        }
示例#10
0
        public BitcoinUnitOfWork(string connectionString)
        {
            _context = new BitcoinContext(connectionString);

            BpiRepository        = new BpiRepository(_context);
            EURRepository        = new EURRepository(_context);
            GBPRepository        = new GBPRepository(_context);
            RootObjectRepository = new RootObjectRepository(_context);
            TimeRepository       = new TimeRepository(_context);
            USDRepository        = new USDRepository(_context);
        }
示例#11
0
        public async Task <ActionResult> AddConfirmedTime(int id)
        {
            Time    timeChosen = TimeRepository.Get(id);
            Meeting meeting    = MeetingRepository.Get(timeChosen.Meeting.Id);

            meeting.ConfirmedTime = timeChosen.Date;
            MeetingRepository.Update(meeting);
            await sendMeetingUpdateMail(meeting);

            return(RedirectToAction("Profile", new { id = meeting.Id }));
        }
示例#12
0
        public List <Time> ReadByDate(DateTime time)
        {
            List <Time> list = new List <Time>();

            using (DbContext context = new DbContext())
            {
                _repository = new TimeRepository(context);
                list        = _repository.ReadByDate(time);
            }

            return(list);
        }
示例#13
0
        public Time ReadByID(int id)
        {
            var time = new Time();

            using (DbContext context = new DbContext())
            {
                _repository = new TimeRepository(context);
                time        = _repository.ReadByID(id);
            }

            return(time);
        }
        public ActionResult Fake()
        {
            UsersRepository    a = new UsersRepository();
            CommentsRepository b = new CommentsRepository();
            TimeRepository     c = new TimeRepository();
            TasksRepository    d = new TasksRepository();

            b.Count();
            d.Count();
            c.Count();
            a.Count();

            return(View());
        }
示例#15
0
        public ActionResult AddNewTimeChoice(int id)
        {
            User       currentUser   = UserRepository.Get(Convert.ToInt32(User.Identity.GetUserId()));
            Time       timeChosen    = TimeRepository.Get(id);
            TimeChoice newTimeChoice = new TimeChoice();

            newTimeChoice.Time    = timeChosen;
            newTimeChoice.User    = currentUser;
            newTimeChoice.Meeting = timeChosen.Meeting;
            TimeChoiceRepository.Add(newTimeChoice);
            updateInvitationStatus(currentUser, timeChosen.Meeting.Id, 1);

            return(RedirectToAction("Profile", new { id = newTimeChoice.Meeting.Id }));
        }
示例#16
0
        public int Create(Time time)
        {
            int result = 0;

            if (string.IsNullOrEmpty(time.NamaLog))
            {
                MessageBox.Show("Nama log harus diisi!", "Peringatan", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return(0);
            }

            if (string.IsNullOrEmpty(time.Tanggal.ToString()))
            {
                MessageBox.Show("Nama log harus diisi!", "Peringatan", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return(0);
            }

            if (string.IsNullOrEmpty(time.Jam.ToString()))
            {
                MessageBox.Show("Jam harus diisi!", "Peringatan", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return(0);
            }

            if (string.IsNullOrEmpty(time.Menit.ToString()))
            {
                MessageBox.Show("Menit harus diisi!", "Peringatan", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return(0);
            }

            if (string.IsNullOrEmpty(time.Detik.ToString()))
            {
                MessageBox.Show("Detik harus diisi!", "Peringatan", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return(0);
            }

            using (DbContext context = new DbContext())
            {
                _repository = new TimeRepository(context);
                result      = _repository.Create(time);
            }

            if (result == 0)
            {
                MessageBox.Show("Log gagal disimpan!", "Gagal",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            return(result);
        }
示例#17
0
        private void Validate(Time time)
        {
            if (string.IsNullOrEmpty(time.Nome))
            {
                throw new ArgumentNullException("Nome");
            }

            if (string.IsNullOrEmpty(time.Sigla))
            {
                throw new ArgumentNullException("Sigla");
            }

            using (var dao = new TimeRepository())
            {
                var timeDB = dao.Find(x =>
                                      x.Nome.Trim().ToLower() == time.Nome.Trim().ToLower() &&
                                      x.TimeId != time.TimeId
                                      );

                if (timeDB != null)
                {
                    throw new ArgumentException("Já existe um Time com este Nome.");
                }
            }

            using (var dao = new TimeRepository())
            {
                var timeDB = dao.Find(x =>
                                      x.Sigla.Trim().ToLower() == time.Sigla.Trim().ToLower() &&
                                      x.TimeId != time.TimeId
                                      );

                if (timeDB != null)
                {
                    throw new ArgumentException("Já existe um Time com esta Sigla.");
                }
            }
        }
示例#18
0
        private void Validate(Posicao posicao)
        {
            if (string.IsNullOrEmpty(posicao.Descricao))
            {
                throw new ArgumentNullException("Nome");
            }

            if (string.IsNullOrEmpty(posicao.Sigla))
            {
                throw new ArgumentNullException("Sigla");
            }

            using (var dao = new PosicaoRepository())
            {
                var posicaoDB = dao.Find(x =>
                                         x.Descricao.Trim().ToLower() == posicao.Descricao.Trim().ToLower() &&
                                         x.PosicaoId != posicao.PosicaoId
                                         );

                if (posicaoDB != null)
                {
                    throw new ArgumentException("Já existe um Posicao com esta Descrição.");
                }
            }

            using (var dao = new TimeRepository())
            {
                var timeDB = dao.Find(x =>
                                      x.Sigla.Trim().ToLower() == posicao.Sigla.Trim().ToLower() &&
                                      x.TimeId != posicao.PosicaoId
                                      );

                if (timeDB != null)
                {
                    throw new ArgumentException("Já existe um Time com esta Sigla.");
                }
            }
        }
示例#19
0
 public ActionResult Create(MeetingCreateViewModel model)
 {
     model.Creator = UserRepository.Get(Convert.ToInt32(User.Identity.GetUserId()));
     if (ModelState.IsValid)
     {
         bool    timesAdded = false;
         Meeting meeting    = new Meeting();
         meeting.Creator     = model.Creator;
         meeting.Description = model.Description;
         meeting.Title       = model.Title;
         meeting.Invitations = new HashSet <Invitation>();
         meeting.Times       = new HashSet <Time>();
         int id = MeetingRepository.Add(meeting);
         if (id != 0)
         {
             foreach (string stringDate in model.Dates)
             {
                 Time     newDate     = new Time();
                 DateTime dateAndTime = new DateTime();
                 if (DateTime.TryParse(stringDate, out dateAndTime))
                 {
                     newDate.Date    = dateAndTime;
                     newDate.Meeting = MeetingRepository.Get(id);
                     if (TimeRepository.add(newDate) != 0)
                     {
                         timesAdded = true;
                     }
                 }
             }
             if (timesAdded)
             {
                 return(RedirectToAction("Profile", new { id = id }));
             }
         }
     }
     return(View());
 }
示例#20
0
        public int Delete(Time time)
        {
            int result = 0;

            if (string.IsNullOrEmpty(time.LogId.ToString()))
            {
                MessageBox.Show("Log ID harus diisi!", "Peringatan", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return(0);
            }

            using (DbContext context = new DbContext())
            {
                _repository = new TimeRepository(context);
                result      = _repository.Delete(time);
            }

            if (result == 0)
            {
                MessageBox.Show("Log gagal dihapus!", "Gagal",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            return(result);
        }
 public TimeController()
 {
     this._timeRepository = new TimeRepository(StringConexao.DefaultConnection);
 }
 public TimeController()
 {
     _repository = new TimeRepository();
 }