Example #1
0
        private DayModel SetDay(DayModel day)
        {
            var list = new List <DateTime>();
            var time = day.Day;

            for (var i = 0; i < 48; i++)
            {
                switch (i)
                {
                case 7:
                    day.ShiftStart = time;
                    break;

                case 17:
                    day.ShiftEnd = time;
                    break;
                }

                for (var j = 0; j < 4; j++)
                {
                    list.Add(time);
                    time = time.AddMinutes(15);
                }
            }

            day.TimeOptions = list;
            return(day);
        }
Example #2
0
        public IHttpActionResult Post([FromBody] DayModel model)
        {
            try
            {
                Day day = new Day
                {
                    Id         = model.Id,
                    Date       = model.Date,
                    Category   = TimeUnit.Categories.Get(model.Type),
                    Hours      = model.Hours,
                    Employee   = TimeUnit.Employees.Get(model.Employee.Id),
                    CategoryId = model.Type,
                    EmployeeId = model.Employee.Id
                };
                if (day.Id == 0)
                {
                    TimeUnit.Days.Insert(day);
                }
                else
                {
                    TimeUnit.Days.Update(day, day.Id);
                }
                TimeUnit.Save();

                foreach (DetailModel task in model.Details)
                {
                    if (task.Deleted)
                    {
                        TimeUnit.Assignments.Delete(task.Id);
                    }
                    else
                    {
                        Assignment detail = new Assignment
                        {
                            Id          = task.Id,
                            Day         = TimeUnit.Days.Get(day.Id),
                            DayId       = day.Id,
                            Description = task.Description,
                            Hours       = task.Hours,
                            Project     = TimeUnit.Projects.Get(task.Project.Id),
                            ProjectId   = task.Project.Id
                        };
                        if (detail.Id == 0)
                        {
                            TimeUnit.Assignments.Insert(detail);
                        }
                        else
                        {
                            TimeUnit.Assignments.Update(detail, detail.Id);
                        }
                    }
                }
                TimeUnit.Save();
                return(Ok());
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }
Example #3
0
        public void CreateTask(TaskValidation taskValidation, DayRepository dayRepository, ToDoTaskRepository taskRepository, DayMapper dayMapper, TextBox textBoxName, TextBox textBoxDate, RichTextBox richTextBoxDescription, int statusValue, int priorityValue)
        {
            bool isCorrect = taskValidation.isInputOk(textBoxName.Text, richTextBoxDescription.Text, textBoxDate.Text);

            if (isCorrect)
            {
                using (var dbContex = new ToDoAppDbContext())
                {
                    dayRepository  = new DayRepository(dbContex);
                    taskRepository = new ToDoTaskRepository(dbContex);
                    var myDay = dayRepository.GetByDate(DateTime.Parse(textBoxDate.Text));
                    if (myDay == null)
                    {
                        dayMapper = new DayMapper();
                        var tempDay = new DayModel();
                        tempDay.Date = DateTime.Parse(textBoxDate.Text);
                        dayRepository.Update(dayMapper.Map(tempDay));
                    }
                    myDay = dayRepository.GetByDate(DateTime.Parse(textBoxDate.Text));
                    taskRepository.Update(new Database.Entities.TaskToDo
                    {
                        Name        = textBoxName.Text,
                        Description = richTextBoxDescription.Text,
                        DayId       = myDay.DayId,
                        Status      = statusValue,
                        Priority    = priorityValue
                    });
                }
                MessageBox.Show("The database was successfully modified");
            }
        }
Example #4
0
 public void CreateCalendar(Action <string> OnSuccess = null)
 {
     //Get how many days have this month
     totalMonthDays = DateTime.DaysInMonth(now.Year, now.Month);
     //Create all empty Day Blocks before the first one which are days from another month
     for (int i = 0; i < DaysFromLastMonth(); i++)
     {
         GameObject newDay   = Instantiate(dayPrefab);
         DayModel   dayModel = new DayModel(false);
         newDay.GetComponent <Day>().dayModel = dayModel;
         newDay.transform.SetParent(monthLayout.transform);
     }
     //Create valid days
     foreach (DayModel dayModel in monthModel)
     {
         //Instantiate Day with DateTime info
         GameObject newDayObject = Instantiate(dayPrefab);
         Day        dayComponent = newDayObject.GetComponent <Day>();
         dayModel.day          = dayComponent;
         dayComponent.dayModel = dayModel;
         //dayComponent.GetAllAssistanceListsFromDB(()=> { });//dayComponent.acceptedRaiders = new List<Raider>(MainController.s_Instance.rosterController.raiders);
         dayComponent.SetDayNum();
         newDayObject.transform.SetParent(monthLayout.transform);
         month.Add(dayComponent);
     }
     GetAllDayAssistanceListsFromDB(OnSuccess, month);
 }
        private void DayClickAction(DayModel _dayModel)
        {
            if (IsMultipleSelect)
            {
                if (_dayModel.Date != DateTime.MinValue)
                {
                    _dayModel.Selected = !_dayModel.Selected;
                }
            }
            else
            {
                if (_dayModel.Date != DateTime.MinValue)
                {
                    _dayModel.Selected = !_dayModel.Selected;

                    var vm         = (CalendarViewModel)BindingContext;
                    var oldselects = vm.SelectedDates;
                    foreach (var item in oldselects)
                    {
                        item.Selected = false;
                    }
                    _dayModel.Selected = true;
                }
            }
        }
Example #6
0
        public DayModel SaveDay(DayModel day)
        {
            SqlConnector connector = new SqlConnector();

            SqlConnection connection = connector.Connection(connstr);

            connection.Open();

            String querry = "INSERT INTO Days(TotalMade, TotalSpent, SoldProductsCount, MostCommonProduct, MostCommonCategory, Date) VALUES(@TotalMade, @TotalSpent, @SoldProductsCount, @MostCommonProduct, @MostCommonCategory, @Date)";

            SqlCommand command = new SqlCommand(querry, connection);

            command.Parameters.AddWithValue("@TotalMade", day.TotalMade);
            command.Parameters.AddWithValue("@TotalSpent", day.TotalSpent);
            command.Parameters.AddWithValue("@SoldProductsCount", day.SoldProductsCount);
            command.Parameters.AddWithValue("@MostCommonProduct", day.MostCommonProduct);
            command.Parameters.AddWithValue("@MostCommonCategory", day.MostCommonCategory);
            command.Parameters.AddWithValue("@Date", day.Date);

            command.ExecuteNonQuery();

            connection.Close();

            return(day);
        }
Example #7
0
        public List <DayModel> QueryMonthInfo(DateTime date)
        {
            var days = dal.QueryByMonth(date).GroupBy(p => p.Date);
            var list = new List <DayModel>();

            foreach (var kv in days)
            {
                var day = new DayModel();
                day.Date = kv.Key;
                var totalMoney = kv.Sum(p => p.UseAmount);
                day.Detail = kv.Select(p => new MoneyModel()
                {
                    ID        = p.MoneyID,
                    IOFlag    = p.IOFlag,
                    UseAmount = p.UseAmount,
                    UseWay    = p.UseWay,
                    Percent   = Math.Round(p.UseAmount * 100 / totalMoney, 2),
                    IsDelete  = false,
                    UseType   = p.TypeName
                }).ToList();

                list.Add(day);
            }

            return(list);
        }
        public JsonResult SaveTemplate(DayModel rModel)
        {
            if (!ModelState.IsValid)
            {
                return(Json(new { ok = false, message = "Validation has failed!" }));
            }

            var dayShedule = Mapper.Map <Day>(rModel);

            _dayRepository.Update(dayShedule);

            dayShedule.Routes.ToList().ForEach(x => x.DayId = dayShedule.Id);

            _dayRepository.SaveChanges();

            if (dayShedule.Id != 0)
            {
                var routesToDelete =
                    _routeBaseRepository.Get()
                    .Where(x => x.DayId.HasValue && x.DayId.Value == dayShedule.Id).ToList().Where(e => dayShedule.Routes.ToList().All(x => x.Id != e.Id));
                _routeBaseRepository.RemoveRange(routesToDelete);
                _routeBaseRepository.AddOrUpdateRange(dayShedule.Routes);

                _routeBaseRepository.SaveChanges();
            }

            return(Json(new { ok = true }));
        }
Example #9
0
        public void DayGenerateDaysTest()
        {
            DayModel model = new DayModel();

            model.GenerateDays(new Day(new DateTime(2017, 11, 11)));
            Assert.IsTrue(model.Day.DateEquals(new Day(new DateTime(2017, 11, 11))));
        }
Example #10
0
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            DateTime onDay = (DateTime)parameter;

            if (value is DaysModel daysModel && targetType == typeof(Brush))
            {
                DayModel dayModel = daysModel.GetDay(onDay);

                if (dayModel == null)
                {
                    return(Brushes.White);
                }

                switch (dayModel.Status)
                {
                case ValidationType.Ok: return(Brushes.White);

                case ValidationType.Notice: return(Brushes.LightBlue);

                case ValidationType.Warning: return(Brushes.Yellow);

                case ValidationType.Error: return(Brushes.Red);

                default: return(Brushes.DeepPink);
                }
            }

            if (targetType == typeof(string))
            {
                return(value.ToString());
            }

            throw new NotSupportedException();
        }
        private async Task <List <DayModel> > CreateMonth(int empId, int year, int month)
        {
            List <DayModel> calendar = new List <DayModel>();
            Employee        emp      = await Unit.People.Get(-1);

            DateTime day = new DateTime(year, month, 1);

            while (day.Month == month)
            {
                DayModel newDay = new DayModel
                {
                    Employee = emp.Master(),
                    Date     = day,
                    DayType  = "empty"
                };
                if (day.DayOfWeek == DayOfWeek.Sunday || day.DayOfWeek == DayOfWeek.Saturday)
                {
                    newDay.DayType = "weekend";
                }
                if (day > DateTime.Today)
                {
                    newDay.DayType = "future";
                }
                if (day < emp.BeginDate || (day > emp.EndDate))
                {
                    newDay.DayType = "future";
                }
                calendar.Add(newDay);
                day = day.AddDays(1);
            }

            return(calendar);
        }
Example #12
0
 public DayPresenter(DayModel model, DayView view)
 {
     this.model     = model;
     this.view      = view;
     view.Month     = model.Month;
     view.Presenter = this;
 }
Example #13
0
        private (PersonDisplayModel person, GroupModel team, DayModel day) Get()
        {
            var person = new PersonDisplayModel
            {
                Category    = _reader["category"] as string ?? string.Empty,
                CategoryKey = _reader["category_key"] as string ?? string.Empty,
                FirstName   = _reader["first_name"] as string ?? string.Empty,
                LastName    = _reader["last_name"] as string ?? string.Empty,
                Id          = _reader["person_id"] as long? ?? 0
            };
            var team = new GroupModel
            {
                Id   = _reader["team_id"] as long? ?? 0,
                Name = _reader["team"] as string ?? string.Empty
            };
            var did = (_reader["day"] as long? ?? 0);
            var day = new DayModel
            {
                DayName = did.AsDay(),
                DayId   = did
            };

            return
                (
                person,
                team,
                day
                );
        }
Example #14
0
        /// <summary>
        /// This function is loading daily task to listBox
        /// </summary>
        private void SetUpMyListBox()
        {
            myTasks = new List <ToDoTaskModel>();
            listBoxDailyTasks.Items.Clear();
            try
            {
                using (var dbContex = new ToDoAppDbContext())
                {
                    dayRepository      = new DayRepository(dbContex);
                    toDoTaskRepository = new ToDoTaskRepository(dbContex);
                    DayModel item = (DayModel)comboBoxDates.SelectedItem;

                    var day        = dayRepository.GetByDate(dayMapper.Map(item).Date);
                    var dailyTasks = toDoTaskRepository.GetByDate(day).AsParallel();
                    if (dailyTasks != null)
                    {
                        listBoxDailyTasks.DisplayMember = "Name";
                        foreach (var task in dailyTasks)
                        {
                            var taskModel = toDoTaskMapper.Map(task);
                            listBoxDailyTasks.Items.Add(taskModel);
                            myTasks.Add(taskModel);
                        }
                        listBoxDailyTasks.Update();
                        listBoxDailyTasks.SelectedItem = listBoxDailyTasks.Items[0];
                        FindNextTask.GetNextTask(myTasks, ref labelNextTaskValue);
                    }
                }
            }catch (Exception e)
            {
                MessageBox.Show("There are no tasks for the selected day");
            }
        }
Example #15
0
        private GroupModel Get(GroupModel team, DayModel day)
        {
            var result = (from t in day.Teams
                          where t.Id == team.Id
                          select t).Single();

            return(result);
        }
Example #16
0
        private bool Has(GroupModel team, DayModel day)
        {
            var count = (from t in day.Teams
                         where t.Id == team.Id
                         select t).Count();

            return(count > 0);
        }
        private bool Has(DayModel day, IList <DayModel> days)
        {
            var r = (from d in days
                     where d.DayId == day.DayId
                     select d);

            return(r.Count() > 0);
        }
        public static void Add(this ReceptionModel src, DayModel day, GroupModel toAdd)
        {
            var result = (from d in src.Days
                          where d.DayId == day.DayId
                          select d).Single();

            result?.Teams.Add(toAdd);
        }
        private GroupModel Get(long id, DayModel foundDay)
        {
            var res = (from d in foundDay.Teams
                       where d.Id == id
                       select d).Single();

            return(res);
        }
Example #20
0
        private DayModel Get(DayModel day)
        {
            var result = (from d in Days
                          where d.DayId == day.DayId
                          select d).Single();

            return(result);
        }
        public void Day_for_2019_04_08()
        {
            var day = new DayModel(_cultureInfo, new LocalDate(2019, 4, 8));

            day.DayOfWeek.Should().Be(IsoDayOfWeek.Monday);
            day.DisplayName.Should().Be("Mo");
            day.Day.Should().Be(8);
        }
Example #22
0
        /// <summary>
        /// DayModel típust konvertál Day típusra (entitás)
        /// </summary>
        /// <param name="day">Átkonvertálandó DayModel</param>
        /// <returns>Day-é konvertált DayModel</returns>
        public static Day ModelToEntity(DayModel day)
        {
            Day newDay = new Day();

            //newDay.Courses = CourseMapper.ModelCollectionToEntityCollection(day.Courses);
            newDay.Id   = day.Id;
            newDay.Day1 = day.Day1.ToString();
            return(newDay);
        }
Example #23
0
        public IActionResult ShowDay(string dayDate, DayModel dayModel)
        {
            dayModel.Tasks       = _context.Tasks.Where(task => task.Date.Date == DateTime.Parse(dayDate).Date);
            dayModel.CurrentDate = dayDate;
            var dateTimeArr = GetTimeIntervals(dayDate);

            ViewData["TimeIntervals"] = new SelectList(dateTimeArr);
            return(View(dayModel));
        }
Example #24
0
        private async void InitCurrentDate(DayModel dayModel)
        {
            if (dayModel.Date == _initDate)
            {
                await Task.Delay(200);

                DayClickAction();
            }
        }
Example #25
0
 public DayViewModel(DayModel dayModel, DateTime initDate)
 {
     _dayModel = dayModel;
     _initDate = initDate;
     _dayModel.PropertyChanged += _dayModel_PropertyChanged;
     DayClick           = new Command(DayClickAction);
     this.SelectedColor = Color.Transparent;
     InitCurrentDate(dayModel);
 }
        //completeaza randul cu datele corespunzatoare
        public static DataRow FillRow(DataRow row, DayModel day)
        {
            row["Nume"]      = day.Nume;
            row["DataStart"] = day.DataStart;
            row["DataStop"]  = day.DataStop;
            row["Frecventa"] = day.Frecvneta;

            return(row);
        }
Example #27
0
    public void PostUpdateDay(Action <string> OnSuccess = null, DayModel dayModelToUpdate = null, Raider newRaider = null)
    {
        //ToDo: This could be splited into more methods to only update the changed variable, not the whole dayModel
        string newDayModelString = JsonManager.SerializeToJson <DayModel>(dayModelToUpdate);
        string newRaiderString   = JsonManager.SerializeToJson <Raider>(newRaider);
        string url = phpFilesServer + "UpdateDay.php";

        WebController.s_Instance.PostWebRequest(url, OnSuccess, new WebRequest.FormField("newDayModel", newDayModelString), new WebRequest.FormField("newRaider", newRaiderString));
    }
Example #28
0
        /// <summary>
        /// Insert new Day
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public IHttpActionResult Post([FromBody] DayModel model)
        {
            try
            {
                Day day = new Day
                {
                    Id       = model.Id,
                    Date     = model.Date,
                    Type     = (DayType)model.Type,
                    Hours    = model.Hours,
                    Employee = TimeKeeperUnit.Employees.Get(model.Employee.Id)
                };
                if (day.Id == 0)
                {
                    TimeKeeperUnit.Calendar.Insert(day);
                }
                else
                {
                    TimeKeeperUnit.Calendar.Update(day, day.Id);
                }
                TimeKeeperUnit.Save();

                foreach (DetailModel task in model.Details)
                {
                    if (task.Deleted && task.Id != 0)
                    {
                        TimeKeeperUnit.Details.Delete(TimeKeeperUnit.Details.Get(task.Id));
                    }
                    else
                    {
                        Detail detail = new Detail
                        {
                            Id          = task.Id,
                            Day         = TimeKeeperUnit.Calendar.Get(day.Id),
                            Description = task.Description,
                            Hours       = task.Hours,
                            Project     = TimeKeeperUnit.Projects.Get(task.Project.Id)
                        };
                        if (detail.Id == 0)
                        {
                            TimeKeeperUnit.Details.Insert(detail);
                        }
                        else
                        {
                            TimeKeeperUnit.Details.Update(detail, detail.Id);
                        }
                    }
                }
                TimeKeeperUnit.Save();
                return(Ok());
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }
Example #29
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            if(e.Parameter is DayModel)
            {
                dayModel = e.Parameter as DayModel;
                DataContext = dayModel;
            }

            base.OnNavigatedTo(e);
        }
Example #30
0
        public void DayGetNextDays()
        {
            DayModel model = new DayModel();
            Day      day   = new Day(new DateTime(2017, 11, 11));

            model.GenerateDays(day);
            Day nextDay = model.GetNextDay();

            Assert.AreEqual(day.DayOfYear + 1, nextDay.DayOfYear);
        }
Example #31
0
        public void DayGetPreviousDays()
        {
            DayModel model = new DayModel();
            Day      day   = new Day(new DateTime(2017, 11, 11));

            model.GenerateDays(day);
            Day previousDay = model.GetPreviousDay();

            Assert.AreEqual(day.DayOfYear - 1, previousDay.DayOfYear);
        }
Example #32
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            if(e.Parameter is DayModel)
            {
                dayModel = e.Parameter as DayModel;
                alarmRepeatSelection = new AlarmRepeatSelection(dayModel.SelectedDaysFlags);
                DataContext = alarmRepeatSelection;
                this.setLlistBoxSelectionStatus();
            }

            base.OnNavigatedTo(e);
        }
Example #33
0
        /// <summary>
        /// Invoked when the application is launched normally by the end user.  Other entry points
        /// will be used when the application is launched to open a specific file, to display
        /// search results, and so forth.
        /// </summary>
        /// <param name="e">Details about the launch request and process.</param>
        protected override void OnLaunched(LaunchActivatedEventArgs e)
        {
            #if DEBUG
            if (System.Diagnostics.Debugger.IsAttached)
            {
                this.DebugSettings.EnableFrameRateCounter = true;
            }
            #endif

            Frame rootFrame = Window.Current.Content as Frame;

            // Do not repeat app initialization when the Window already has content,
            // just ensure that the window is active
            if (rootFrame == null)
            {
                // Create a Frame to act as the navigation context and navigate to the first page
                rootFrame = new Frame();

                // TODO: change this value to a cache size that is appropriate for your application
                rootFrame.CacheSize = 1;

                // Set the default language
                rootFrame.Language = Windows.Globalization.ApplicationLanguages.Languages[0];

                if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
                {
                    // TODO: Load state from previously suspended application
                }

                // Place the frame in the current Window
                Window.Current.Content = rootFrame;
            }

            if (rootFrame.Content == null)
            {
                DayModel = new DayModel();
                rootFrame.Navigate(typeof(MainPage), DayModel);
                // Removes the turnstile navigation for startup.
                if (rootFrame.ContentTransitions != null)
                {
                    this.transitions = new TransitionCollection();
                    foreach (var c in rootFrame.ContentTransitions)
                    {
                        this.transitions.Add(c);
                    }
                }

                rootFrame.ContentTransitions = null;
                rootFrame.Navigated += this.RootFrame_FirstNavigated;

                // When the navigation stack isn't restored navigate to the first page,
                // configuring the new page by passing required information as a navigation
                // parameter
                if (!rootFrame.Navigate(typeof(MainPage), e.Arguments))
                {
                    throw new Exception("Failed to create initial page");
                }
            }

            // Ensure the current window is active
            Window.Current.Activate();
        }