Exemplo n.º 1
0
     private SelectList GetWageSchemaDetails( AdminServices adminServ, string AdminEmail )
     {
         var WageSchemas = new List<WageSchema>();
         var result1 = adminServ.GetWageSchemasForUserByProfession( AdminEmail);
         if (result1.Success)
         {
             WageSchemas.AddRange(result1.ReturnValue);
         }
         var result2 = adminServ.GetWageSchemasForUser(AdminEmail);
         if (result2.Success)
         {
             WageSchemas.AddRange(result2.ReturnValue);
         }
         if (WageSchemas.Count() == 0)
         {
             ModelState.AddModelError(string.Empty, "inga löneschema funna");
             return   new SelectList(new List<SelectListItem>(), "WageSchemaID", "Title");
         }
          return  new SelectList(WageSchemas, "WageSchemaID", "Title");
 }
Exemplo n.º 2
0
 //public PartialViewResult GetWageSchemaDetailsForUser(int WageSchemaID  )
         public JsonResult GetWageSchemaDetailsForUser(int WageSchemaID)
     {
         var adminService = new AdminServices(uow);
                var detailsResult = adminService.GetWageSchemaDetailsForUser(WageSchemaID);
         if (!detailsResult.Success)
         {
             //return PartialView(new List<WageSchemaDetail>() { new WageSchemaDetail() });
             return Json(new List<WageSchemaDetail>() { new WageSchemaDetail() });
         }
         var xx = detailsResult.ReturnValue.Count();
         var retResult = detailsResult.ReturnValue.OrderBy(o => o.Day).ThenBy(o => o.StartTime).ThenBy(o => o.EndTime).ToList();
         return Json( retResult   );
     }
Exemplo n.º 3
0
 public async Task<IActionResult> AddWageSchemaDetails()
 {
         var adminServ = new AdminServices(uow);
     var appUser = await GetCurrentUserAsync();
     AddWageSchemaDetailsViewModel vm = new AddWageSchemaDetailsViewModel();
     vm.Days = GetDays();
     vm.StartHours = GetHours();
     vm.StartMinutes = GetMinutes();
     vm.EndHours = GetHours();
     vm.EndMinutes = GetMinutes();
     vm.wageSchemas = GetWageSchemaDetails(adminServ, appUser.Email);
         return View(vm);
 }
Exemplo n.º 4
0
        public async Task<IActionResult> AddWageSchemaDetails( AddWageSchemaDetailsViewModel vm )
        {
                var adminServ = new AdminServices(uow);
                var appUser = await GetCurrentUserAsync();

            if ( ModelState.IsValid)
            {
                var res = adminServ.AddWageSchemaDetails(vm.SelectedWageSchema,  vm.SelectedDay, vm.StartHour, vm.StartMinute, vm.EndHour, vm.EndMinute   ); 
            }

            vm.Days = GetDays();
            vm.StartHours = GetHours();
            vm.StartMinutes = GetMinutes();
            vm.EndHours = GetHours();
            vm.EndMinutes = GetMinutes();
            vm.wageSchemas = GetWageSchemaDetails(adminServ, appUser.Email);
            return View(vm);
        }
Exemplo n.º 5
0
        public async Task<IActionResult> AddWageSchemaForUser(AddWageSchemaForUserViewModel vm)
        {
            vm.Users = new SelectList(new List<SelectListItem>(), "Value", "Text");
            if (ModelState.IsValid)
            {
                var adminServ = new AdminServices(uow);
                var currentAdmin = await GetCurrentUserAsync();
                var result = adminServ.GetUsersForAdmin(currentAdmin.Email);

                if (!result.Success)
                {
                    ModelState.AddModelError(string.Empty, result.Message);
                    return View(vm);
                }
                var result2 = adminServ.AddWageSchemaForUser( currentAdmin.Email  ,vm.SelectedUser, vm.Title, vm.HourlyWage);
                if (!result2.Success)
                {
                    ModelState.AddModelError(string.Empty, result.Message);
                    return View(vm);
                }
                vm.Users = CreateUserList(result.ReturnValue);
                vm.Message = result2.Message;
                return View(vm);
            }
            ModelState.AddModelError(string.Empty, "felaktig inmatning");
            return View(vm);
        }
Exemplo n.º 6
0
 public async Task<IActionResult> AddWageSchemaForUser()
 {
     var vm = new AddWageSchemaForUserViewModel(); 
     var adminServ = new AdminServices(uow);
     var currentAdmin = await GetCurrentUserAsync();
     var result = adminServ.GetUsersForAdmin( currentAdmin.Email );
     
     if ( !result.Success)
     {
         vm.Users = new SelectList(new List<SelectListItem>(), "Value", "Text");
         return View(vm);
     }
     vm.Users = CreateUserList(result.ReturnValue);
     return View(vm);
 }
Exemplo n.º 7
0
        public async Task<IActionResult> AddWageSchemaForProfession(AddWageSchemaForProfessionViewModel  vm)
        {

            var adminServ = new AdminServices(uow);

            var compServ = new CompanyServices(uow);
            var currentUser = await GetCurrentUserAsync();
            var compResult = compServ.GetCompaniesForUser(currentUser.Email);
            vm.Companies = CreateCompanyList(compResult.ReturnValue);
            vm.Professions = new SelectList(new List<SelectListItem>(), "Value", "Text");

            if (ModelState.IsValid)
            {
                var result = adminServ.AddWageSchema(Convert.ToInt32( vm.SelectedProfession) , vm.Title, vm.HourlyWage );
                if (result.Success)
                {
                    vm.Message = result.Message;
                    return View(vm);
                }
                ModelState.AddModelError(string.Empty, result.Message);
                return View(vm);
            }
            ModelState.AddModelError(string.Empty, "incorrect input");
            return View(vm);
        }
Exemplo n.º 8
0
        public async Task<IActionResult> AddProfession(AddProfessionViewModel  vm)
        {
            var compServ = new CompanyServices(uow);
            var appUser = await GetCurrentUserAsync();
            var compResult = compServ.GetCompaniesForUser(appUser.Email);
            vm.Companies = CreateCompanyList(compResult.ReturnValue);
            if ( ModelState.IsValid)
            {
                var currentUser = uow.UserRepository.GetEagerLoad(u => u.Email.Equals(appUser.Email, StringComparison.OrdinalIgnoreCase) ).FirstOrDefault();
                var adminServices = new AdminServices(uow);
                var result = adminServices.Addprofession(appUser.Email,  vm.SelectedValue,   currentUser.UserID , vm.Title, vm.Description); 
if( result.Success)
                {
                    vm.Message = result.Message;
                    return View(vm); 
                }
                else
                {
                    ModelState.AddModelError(string.Empty, result.Message);
                    return View(vm);
                }
            }
            ModelState.AddModelError(string.Empty, "incorrect input");
            return View(vm);
        }
Exemplo n.º 9
0
     public async Task<IActionResult> AddStandardUser(AddStandardUserViewModel vm)
     {
 if (ModelState.IsValid)
 {
     var currentAdmin = await  GetCurrentUserAsync();
     var adminServices = new AdminServices(uow);
     var result = adminServices.AddStandardUser(currentAdmin.Email, vm.UserID, vm.FirstName, vm.LastName, vm.PhoneNumber, vm.UserName, vm.UserCode, vm.Email );
     if (result.Success)
     {
         vm.Message = result.Message;
         return View(vm);
     }
     else
     {
         ModelState.AddModelError(string.Empty, result.Message);
         return View(vm);
     }
 }
 ModelState.AddModelError(string.Empty, "Incorrect input");
         return View(vm);
     }