コード例 #1
0
ファイル: HolidaysController.cs プロジェクト: tayduivn/ERP-1
        public ActionResult Edit(HolidaysViewModel model)
        {
            if (ModelState.IsValid)
            {
                if (Request["Submit"] == "Save")
                {
                    var Holidays = HolidaysRepository.GetHolidaysById(model.Id);
                    AutoMapper.Mapper.Map(model, Holidays);
                    Holidays.ModifiedUserId = WebSecurity.CurrentUserId;
                    Holidays.ModifiedDate   = DateTime.Now;
                    HolidaysRepository.UpdateHolidays(Holidays);

                    TempData[Globals.SuccessMessageKey] = App_GlobalResources.Wording.UpdateSuccess;
                    return(RedirectToAction("Index"));
                }

                return(View(model));
            }

            return(View(model));

            //if (Request.UrlReferrer != null)
            //    return Redirect(Request.UrlReferrer.AbsoluteUri);
            //return RedirectToAction("Index");
        }
コード例 #2
0
        public IActionResult SubmitRequest(HolidaysViewModel holidaysViewModel)
        {
            base.CheckForLogin();

            if (ModelState.IsValid)
            {
                bool approved = false;
                if (new UserRepository(new UserSQLContext()).GetUser(Convert.ToInt32(HttpContext.Session.GetInt32("id"))).Role.Rights.Any(f => f.Id == 8))
                {
                    approved = true;
                }
                if (holidaysViewModel.DateStart != DateTime.MinValue && holidaysViewModel.DateEnd != DateTime.MinValue && holidaysViewModel.DateStart < holidaysViewModel.DateEnd && !string.IsNullOrEmpty(holidaysViewModel.Description))
                {
                    HolidayRequest holidayRequest = new HolidayRequest(Convert.ToInt32(HttpContext.Session.GetInt32("id")), (DateTime)holidaysViewModel.DateStart, (DateTime)holidaysViewModel.DateEnd, holidaysViewModel.Description, approved);
                    new UserRepository(new UserSQLContext()).AddHolidayRequest(holidayRequest);
                    ConfirmHoliday();
                }
                else
                {
                    WrongHoliday();
                }
            }
            UserRepository userRep = new UserRepository(new UserSQLContext());

            holidaysViewModel.HasApproveHolidayRight    = (userRep.GetUser(Convert.ToInt32(HttpContext.Session.GetInt32("id"))).Role.Rights.Any(f => f.Id == 8) ? true : false);
            holidaysViewModel.AllholidayRequests        = userRep.GetAllHolidayRequests();
            holidaysViewModel.UnapprovedholidayRequests = userRep.GetUnapprovedHolidayRequests();
            holidaysViewModel.UserholidayRequests       = userRep.GetUserHolidayRequests(Convert.ToInt32(HttpContext.Session.GetInt32("id")));

            return(View("Holidays", holidaysViewModel));
        }
コード例 #3
0
        public IActionResult Holidays()
        {
            base.CheckForLogin();

            UserRepository    userRep           = new UserRepository(new UserSQLContext());
            HolidaysViewModel holidaysViewModel = new HolidaysViewModel((userRep.GetUser(Convert.ToInt32(HttpContext.Session.GetInt32("id"))).Role.Rights.Any(f => f.Id == 8) ? true : false),
                                                                        userRep.GetAllHolidayRequests(), userRep.GetUnapprovedHolidayRequests(), userRep.GetUserHolidayRequests(Convert.ToInt32(HttpContext.Session.GetInt32("id"))));

            return(View(holidaysViewModel));
        }
コード例 #4
0
        public IActionResult GetHolidays()
        {
            try
            {
                var viewModel = new HolidaysViewModel
                {
                    Holidays = holidayService.GetAll()
                };

                return(PartialView("_GetHolidays", viewModel));
            }
            catch (Exception e)
            {
                return(BadRequest(e.Message));
            }
        }
コード例 #5
0
        public IActionResult Index()
        {
            try
            {
                var viewModel = new HolidaysViewModel
                {
                    Holidays = holidayService.GetAll()
                };

                return(View(viewModel));
            }
            catch (Exception e)
            {
                return(BadRequest(e.Message));
            }
        }
コード例 #6
0
        /// <summary>
        /// Executes once LoadRequest has executed. Will also happen when deserializing cached data
        /// </summary>
        public override object Deserialize(DayLoadContext loadContext, Type objectType, Stream stream)
        {
            if (stream == null)
                throw new ArgumentNullException("stream");

            string html = PageParser.GetHtml(stream);
            var holidays = PageParser.ExtractHolidaysFromHtml(html);
            var viewModel = new HolidaysViewModel(loadContext);

            foreach (Entry entry in holidays)
            {
                viewModel.Holidays.Add(entry);
            }

            return viewModel;
        }
コード例 #7
0
        /// <summary>
        /// Executes once LoadRequest has executed. Will also happen when deserializing cached data
        /// </summary>
        public override object Deserialize(DayLoadContext loadContext, Type objectType, Stream stream)
        {
            if (stream == null)
            {
                throw new ArgumentNullException("stream");
            }

            string html      = PageParser.GetHtml(stream);
            var    holidays  = PageParser.ExtractHolidaysFromHtml(html);
            var    viewModel = new HolidaysViewModel(loadContext);

            foreach (Entry entry in holidays)
            {
                viewModel.Holidays.Add(entry);
            }

            return(viewModel);
        }
コード例 #8
0
ファイル: HolidaysController.cs プロジェクト: tayduivn/ERP-1
        public ActionResult Create(HolidaysViewModel model)
        {
            if (ModelState.IsValid)
            {
                var Holidays = new Domain.Staff.Entities.Holidays();
                AutoMapper.Mapper.Map(model, Holidays);
                Holidays.IsDeleted      = false;
                Holidays.CreatedUserId  = WebSecurity.CurrentUserId;
                Holidays.ModifiedUserId = WebSecurity.CurrentUserId;
                Holidays.CreatedDate    = DateTime.Now;
                Holidays.ModifiedDate   = DateTime.Now;
                HolidaysRepository.InsertHolidays(Holidays);

                TempData[Globals.SuccessMessageKey] = App_GlobalResources.Wording.InsertSuccess;
                return(RedirectToAction("Index"));
            }
            return(View(model));
        }
コード例 #9
0
		public TimeTrackingTabsViewModel(SKDTabItems skdTabItems)
		{
			SKDTabItems = skdTabItems;
			EditFilterCommand = new RelayCommand(OnEditFilter, CanEditFilter);
			DayIntervalsViewModel = new DayIntervalsViewModel();
			ScheduleSchemesViewModel = new ScheduleSchemesViewModel();
			HolidaysViewModel = new HolidaysViewModel();
			SchedulesViewModel = new SchedulesViewModel();
			TimeTrackingViewModel = new TimeTrackingViewModel();
			if (CanSelectDayIntervals) 
				IsDayIntervalsSelected = true;
			else if (CanSelectScheduleSchemes) 
				IsScheduleSchemesSelected = true;
			else if (CanSelectHolidays) 
				IsHolidaysSelected = true;
			else if (CanSelectSchedules) 
				IsSchedulesSelected = true;
			else if (CanSelectTimeTracking) 
				IsTimeTrackingSelected = true;
		}
コード例 #10
0
ファイル: SkudModule.cs プロジェクト: saeednazari/Rubezh
		public override void CreateViewModels()
		{
			SKDManager.UpdateConfiguration();

			ServiceFactory.Events.GetEvent<ShowSkudEvent>().Unsubscribe(OnShowSkud);
			ServiceFactory.Events.GetEvent<ShowSkudEvent>().Subscribe(OnShowSkud);

			_skudViewModel = new SkudViewModel();
			_employeeCardIndexViewModel = new EmployeeCardIndexViewModel();
			_employeeDepartmentsViewModel = new EmployeeDepartmentsViewModel();
			_employeeGroupsViewModel = new EmployeeGroupsViewModel();
			_employeePositionsViewModel = new EmployeePositionsViewModel();
			_passCardDesignerViewModel = new PassCardsDesignerViewModel();
			DevicesViewModel = new DevicesViewModel();
			LibraryViewModel = new LibraryViewModel();
			TimeIntervalsViewModel = new TimeIntervalsViewModel();
			SlideDayIntervalsViewModel = new SlideDayIntervalsViewModel();
			SlideWeekIntervalsViewModel = new SlideWeekIntervalsViewModel();
			WeeklyIntervalsViewModel = new WeeklyIntervalsViewModel();
			HolidaysViewModel = new HolidaysViewModel();
		}
コード例 #11
0
ファイル: HolidaysController.cs プロジェクト: tayduivn/ERP-1
        public ActionResult Edit(int?Id)
        {
            var Holidays = HolidaysRepository.GetHolidaysById(Id.Value);

            if (Holidays != null && Holidays.IsDeleted != true)
            {
                var model = new HolidaysViewModel();
                AutoMapper.Mapper.Map(Holidays, model);

                //if (model.CreatedUserId != Erp.BackOffice.Helpers.Common.CurrentUser.Id && Erp.BackOffice.Helpers.Common.CurrentUser.UserTypeId != 1)
                //{
                //    TempData["FailedMessage"] = "NotOwner";
                //    return RedirectToAction("Index");
                //}

                return(View(model));
            }
            if (Request.UrlReferrer != null)
            {
                return(Redirect(Request.UrlReferrer.AbsoluteUri));
            }
            return(RedirectToAction("Index"));
        }
コード例 #12
0
ファイル: HolidaysController.cs プロジェクト: tayduivn/ERP-1
        public ViewResult Create()
        {
            var model = new HolidaysViewModel();

            return(View(model));
        }
コード例 #13
0
		public HolidaysMenuViewModel(HolidaysViewModel context)
		{
			Context = context;
		}
コード例 #14
0
 protected static void CreateViewModel()
 {
     viewModel = new HolidaysViewModel();
 }