Ejemplo n.º 1
0
        public async Task <IActionResult> OnPostAsync(long id)
        {
            Salary = await _db.Salaries.FindAsync(id);

            if (Salary == null)
            {
                return(NotFound());
            }


            var gross_salary = BasicSalary + HouseRent + MedicalBill + MedicalBill + Other;
            var net_salary   = gross_salary - (TaxDeduction + OtherDeduction + ProvidentFundDeduction);


            Salary.BasicSalary            = BasicSalary;
            Salary.GrossSalary            = gross_salary;
            Salary.HouseRent              = HouseRent;
            Salary.MedicalBill            = MedicalBill;
            Salary.MobileBill             = MobileBill;
            Salary.NetSalary              = net_salary;
            Salary.Other                  = Other;
            Salary.OtherDeduction         = OtherDeduction;
            Salary.ProvidentFundDeduction = ProvidentFundDeduction;
            Salary.TaxDeduction           = TaxDeduction;
            Salary.TotalDeduction         = gross_salary - net_salary;

            await _db.SaveChangesAsync();

            return(RedirectToPage("./EmployeeSalaryList"));
        }
        public async Task <IActionResult> OnPostUpdateProfileData()
        {
            if (Name != null && Name != "" && Username != null && Username != "")
            {
                if (Username != _accountManage.User.UserName)
                {
                    var users = _db.Users.Where(a => a.UserName == Username).ToList();
                    if (users != null)
                    {
                        if (users.Count > 0)
                        {
                            UsernameExisted = true;
                            return(Page());
                        }
                    }
                }



                var user = await _db.Users.FindAsync(_accountManage.User.Id);

                user.Name     = Name;
                user.UserName = Username;
                await _db.SaveChangesAsync();

                _accountManage.User.Name     = Name;
                _accountManage.User.UserName = Username;
                return(RedirectToPage());
            }
            return(Page());
        }
        public async Task <IActionResult> OnPostAsync(long id)
        {
            var employee = await _db.Users.Include(a => a.Salary).SingleAsync(a => a.Id == id);

            if (employee == null)
            {
                return(NotFound());
            }

            //double gs;
            //double.TryParse(gross_salary, out gs);
            //double ns;
            //double.TryParse(net_salary, out ns);
            var gross_salary = BasicSalary + HouseRent + MedicalBill + MedicalBill + Other;
            var net_salary   = gross_salary - (TaxDeduction + OtherDeduction + ProvidentFundDeduction);

            employee.Salary = new Salary
            {
                BasicSalary            = BasicSalary,
                GrossSalary            = gross_salary,
                HouseRent              = HouseRent,
                MedicalBill            = MedicalBill,
                MobileBill             = MobileBill,
                NetSalary              = net_salary,
                Other                  = Other,
                OtherDeduction         = OtherDeduction,
                ProvidentFundDeduction = ProvidentFundDeduction,
                TaxDeduction           = TaxDeduction,
                TotalDeduction         = gross_salary - net_salary
            };

            await _db.SaveChangesAsync();

            return(RedirectToPage("./ManageSalaryDetails"));
        }
Ejemplo n.º 4
0
        public async Task <IActionResult> OnGetDelete(long id)
        {
            var ff = await _db.LeaveCategories.FindAsync(id);

            _db.LeaveCategories.Remove(ff);
            await _db.SaveChangesAsync();

            return(RedirectToPage());
        }
Ejemplo n.º 5
0
        public async Task <IActionResult> OnGetDeleteAsync(long id)
        {
            var notice = await _db.Notices.FindAsync(id);

            _db.Notices.Remove(notice);
            await _db.SaveChangesAsync();

            return(RedirectToPage());
        }
        public async Task <IActionResult> OnPostAsync()
        {
            var leave = await _db.LeaveCategories.FindAsync(LeaveCategory.Id);

            leave.Title = LeaveCategory.Title;
            leave.Days  = LeaveCategory.Days;
            await _db.SaveChangesAsync();

            return(RedirectToPage("./LeaveCategory"));
        }
        public async Task <IActionResult> OnPostAsync()
        {
            if (ModelState.IsValid)
            {
                _db.LeaveCategories.Add(LeaveCategory);
                await _db.SaveChangesAsync();

                return(RedirectToPage("./LeaveCategory"));
            }
            return(Page());
        }
Ejemplo n.º 8
0
        public async Task <IActionResult> OnPostAsync(List <string> designations, string department_name, long?id)
        {
            var _id = (long)id;

            if (designations.Count > 0 && department_name != "" && department_name != null)
            {
                var _department = await _db.Departments.FindAsync(_id);

                if (_department == null)
                {
                    return(NotFound());
                }
                _db.Departments.Remove(_department);
                await _db.SaveChangesAsync();

                var d = new DepartmentModel();
                d.Name = department_name;

                d.Designation = new List <DesignationModel>();
                foreach (var desig_name in designations)
                {
                    if (desig_name != "" && desig_name != null)
                    {
                        var de = new DesignationModel();
                        de.Name = desig_name;
                        d.Designation.Add(de);
                    }
                }

                if (d.Designation.Count == 0)
                {
                    return(Page());
                }

                _db.Departments.Add(d);
                await _db.SaveChangesAsync();

                return(RedirectToPage("/AdminPages/Department/Departmentlist"));
            }
            return(Page());
        }
        public async Task <string> ActivateOrDeactivateEmployeeAsync(long id)
        {
            var user = await _db.Users.FindAsync(id);

            if (user == null)
            {
                return("failed");
            }

            user.Status = !user.Status;
            await _db.SaveChangesAsync();

            if (user.Status == true)
            {
                return("active");
            }
            else
            {
                return("deactive");
            }
        }
        public async Task <IActionResult> OnPostAsync()
        {
            if (ModelState.IsValid)
            {
                _db.Holidays.Add(Holiday);
                await _db.SaveChangesAsync();

                return(RedirectToPage("/AdminPages/Settings/HolidayList"));
            }

            return(RedirectToPage());
        }
Ejemplo n.º 11
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (StartDate.CompareTo(EndDate) > 0)
            {
                InValidDateSelected = true;

                var lc = await _db.LeaveCategories.AsNoTracking().ToListAsync();

                LeaveCategories = new List <SelectListItem>();
                if (lc != null)
                {
                    if (lc.Count > 0)
                    {
                        foreach (var item in lc)
                        {
                            LeaveCategories.Add(new SelectListItem {
                                Value = item.Id.ToString(), Text = item.Title
                            });
                        }
                    }
                }

                ViewData["User_Name"] = _accountManage.User.Name;
                ViewData.Add("ProfileImg", _accountManage.User.ProfileImageSrc);
                return(Page());
            }

            var leavecategory = await _db.LeaveCategories.FindAsync(LeaveCategory);

            var user = await _db.Users.Include(a => a.LeaveApplications).SingleAsync(a => a.Id == _accountManage.User.Id);

            var totalDays = EndDate - StartDate;


            var leaveApplication = new LeaveApplication
            {
                EndDate       = EndDate,
                StartDate     = StartDate,
                LeaveCategory = leavecategory,
                Reason        = Reason,
                Days          = (int)(totalDays.TotalDays + 1),
                User          = user,
                Status        = LeaveApplicationStatus.Pending,
                AppliedDate   = DateTime.Now
            };

            user.LeaveApplications.Add(leaveApplication);

            await _db.SaveChangesAsync();

            return(RedirectToPage("./Leave_Application"));
        }
        public async Task <IActionResult> OnGetDeleteAsync(long id)
        {
            var holiday = await _db.Holidays.FindAsync(id);

            if (holiday == null)
            {
                return(NotFound());
            }
            _db.Holidays.Remove(holiday);
            await _db.SaveChangesAsync();

            return(RedirectToPage());
        }
        public async Task <IActionResult> OnGetDeleteAsync(long id)
        {
            var notice = await _db.RecruitementNotices.Include(a => a.Applicants).SingleAsync(o => o.Id == id);

            if (notice == null)
            {
                return(NotFound());
            }

            _db.RecruitementNotices.Remove(notice);
            await _db.SaveChangesAsync();

            return(RedirectToPage());
        }
        public async Task <IActionResult> OnPostUpdateProfileData()
        {
            if (Name != null && Name != "")
            {
                var user = await _db.Users.FindAsync(_accountManage.User.Id);

                user.Name = Name;
                await _db.SaveChangesAsync();

                _accountManage.User.Name = Name;
                return(RedirectToPage());
            }
            return(Page());
        }
Ejemplo n.º 15
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (ModelState.IsValid)
            {
                UserModel exist_user = null;
                try
                {
                    exist_user = _db.Users.Single(u => u.Email.ToLower() == Email.ToLower());
                }
                catch (Exception ex)
                {
                }
                if (exist_user != null)
                {
                    EmailExist = true;
                    return(Page());
                }

                if (Password != Password2)
                {
                    PasswordDidntMatch = true;
                    return(Page());
                }


                var last_user = _db.Users.Last();

                exist_user = new UserModel
                {
                    Name     = FirstName + " " + LastName,
                    Email    = Email,
                    Password = Password,
                    UserType = UserType.Career,
                    UserName = "******" + last_user.Id
                };

                _db.Users.Add(exist_user);
                await _db.SaveChangesAsync();

                _accountManage.IsLoggedIn = true;
                _accountManage.User       = exist_user;

                return(RedirectToPage("/CareerPages/Career_Dashboard"));
            }
            else
            {
                return(Page());
            }
        }
        public async Task <IActionResult> OnPostAsync(long id)
        {
            if (ModelState.IsValid)
            {
                var u = await _db.Users.FindAsync(id);

                u.InterviewDate        = new DateTime(InterviewDate.Year, InterviewDate.Month, InterviewDate.Day, InterviewTime.Hour, InterviewTime.Minute, InterviewTime.Second);
                u.SelectedForInterview = true;

                await _db.SaveChangesAsync();

                return(RedirectToPage("./Recruitment_Applicant_List"));
            }
            return(Page());
        }
        public async Task <IActionResult> OnPostAsync()
        {
            if (ModelState.IsValid)
            {
                foreach (var item in Days)
                {
                    var item_to_update = await _db.WeekDays.FindAsync(item.Id);

                    item_to_update.IsWorkingDay = item.IsWorkingDay;
                    await _db.SaveChangesAsync();
                }

                return(RedirectToPage(new { saved = true }));
            }
            return(RedirectToPage());
        }
        public async Task <IActionResult> OnGetDelete(long id)
        {
            UserModel career_user = null;

            career_user = await _db.Users.FindAsync(id);

            if (career_user == null)
            {
                return(NotFound());
            }
            career_user.SelectedForInterview = false;
            career_user.InterviewDate        = null;
            await _db.SaveChangesAsync();

            return(RedirectToPage());
        }
        public async Task <IActionResult> OnPostAsync()
        {
            var holiday = await _db.Holidays.FindAsync(Holiday.Id);

            if (holiday == null)
            {
                return(NotFound());
            }
            holiday.Description = Holiday.Description;
            holiday.Name        = Holiday.Name;
            holiday.StartDate   = Holiday.StartDate;
            holiday.EndDate     = Holiday.EndDate;

            await _db.SaveChangesAsync();

            return(RedirectToPage("./HolidayList"));
        }
Ejemplo n.º 20
0
        public async Task <IActionResult> OnPostAsync(long id, string status)
        {
            LeaveApplication = await _db.LeaveApplications.Include(a => a.User).ThenInclude(o => o.Attendances).SingleAsync(a => a.Id == id);

            switch (status)
            {
            case "Pending":
                LeaveApplication.Status = LeaveApplicationStatus.Pending;
                break;

            case "Approved":
                LeaveApplication.Status = LeaveApplicationStatus.Approved;
                break;

            case "Rejected":
                LeaveApplication.Status = LeaveApplicationStatus.Rejected;
                break;

            case "Default":
                LeaveApplication.Status = LeaveApplicationStatus.Pending;
                break;
            }

            if (LeaveApplication.Status == LeaveApplicationStatus.Approved)
            {
                for (int i = 0; i < LeaveApplication.Days; i++)
                {
                    var new_date = LeaveApplication.StartDate.AddDays(i);
                    LeaveApplication.User.Attendances.Add(new Attendance
                    {
                        Status = AttendanceStatus.InLeave,
                        Date   = new_date,
                        Day    = new_date.Day,
                        Month  = new_date.Month,
                        Year   = new_date.Year
                    });
                }
            }

            await _db.SaveChangesAsync();

            return(RedirectToPage("./LeaveApplicationList"));
        }
Ejemplo n.º 21
0
        public async Task <IActionResult> OnGetDeleteDepartmentAsync(long?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            var department = await _db.Departments.Include(a => a.Designation).AsNoTracking().FirstOrDefaultAsync(m => m.Id == id);

            if (department == null)
            {
                return(NotFound());
            }

            _db.Departments.Remove(department);
            await _db.SaveChangesAsync();

            return(RedirectToPage());
        }
        public async Task <IActionResult> OnPostChangePassword()
        {
            OldPasswordDidntMatch = false;
            NewPasswordDidntMatch = false;

            if (_accountManage.User.Password == OldPassword)
            {
                if (NewPassword != "" && NewPassword2 != "" && NewPassword != null && NewPassword2 != null)
                {
                    if (NewPassword == NewPassword2)
                    {
                        var user = await _db.Users.FindAsync(_accountManage.User.Id);

                        user.Password = NewPassword;
                        _accountManage.User.Password = NewPassword;
                        await _db.SaveChangesAsync();

                        return(RedirectToPage());
                    }
                    else
                    {
                        NewPasswordDidntMatch = true;
                        ViewData["User_Name"] = _accountManage.User.Name;
                        ViewData.Add("ProfileImg", _accountManage.User.ProfileImageSrc);
                        return(Page());
                    }
                }
                else
                {
                    ViewData["User_Name"] = _accountManage.User.Name;
                    ViewData.Add("ProfileImg", _accountManage.User.ProfileImageSrc);
                    return(Page());
                }
            }
            else
            {
                OldPasswordDidntMatch = true;
                ViewData["User_Name"] = _accountManage.User.Name;
                ViewData.Add("ProfileImg", _accountManage.User.ProfileImageSrc);
                return(Page());
            }
        }
Ejemplo n.º 23
0
        public async Task <string> ApplyForPost(long post_id, long applicant_id)
        {
            try
            {
                var notice     = _db.RecruitementNotices.Include(o => o.Applicants).Single(i => i.Id == post_id);
                var CareerUser = await _db.Users.FindAsync(applicant_id);

                CareerUser.DateOfApplication = DateTime.Now;
                CareerUser.Department        = notice.Department;
                CareerUser.Designation       = notice.Designation;
                notice.Applicants.Add(CareerUser);
                await _db.SaveChangesAsync();

                Thread.Sleep(2000);
                return("success");
            }
            catch
            {
                return("failed");
            }
        }
Ejemplo n.º 24
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            var notice = await _db.Notices.FindAsync(Notice.Id);

            if (notice == null)
            {
                return(NotFound());
            }

            notice.Published   = Notice.Published;
            notice.Title       = Notice.Title;
            notice.Description = Notice.Description;

            await _db.SaveChangesAsync();

            return(RedirectToPage("/AdminPages/Notice/ManageNotice"));
        }
        public async Task <IActionResult> OnPostAsync(string title, string first_name, string last_name, string father_name, string mother_name,
                                                      string present_address, string permanent_address, IFormFile profile_img, string phone_number, string mobile_number,
                                                      DateTime date_of_birth, string gender, string marritual_status, string national_id, string religion, string nationality,
                                                      string email, string[] qualification, string[] passing_year, string[] subject, string[] grade, string[] university,
                                                      string[] company_name, DateTime?[] duration_from, string[] company_address, DateTime?[] duration_to, string[] role)
        {
            UserModel user = null;

            user = _db.Users.Include(a => a.Resume).Include(a => a.Resume.Experiences).Include(a => a.Resume.EducationalDetails).Single(aa => aa.Id == _accountManage.User.Id);
            if (user == null)
            {
                return(NotFound());
            }

            Resume resume = new Resume();

            resume.Title       = title;
            resume.FirstName   = first_name;
            resume.LastName    = last_name;
            resume.DateOfBirth = date_of_birth;


            List <string> qualifications = new List <string>();

            foreach (var item in qualification)
            {
                if (item != "" && item != null)
                {
                    qualifications.Add(item);
                }
            }

            List <string> Subjects = new List <string>();

            foreach (var item in subject)
            {
                Subjects.Add(item);
            }

            List <string> Institutes = new List <string>();

            foreach (var item in university)
            {
                Institutes.Add(item);
            }

            List <string> passing_years = new List <string>();

            foreach (var item in passing_year)
            {
                passing_years.Add(item);
            }


            List <string> resutls = new List <string>();

            foreach (var item in grade)
            {
                resutls.Add(item);
            }


            List <string> company_names = new List <string>();

            foreach (var item in company_name)
            {
                if (item != null && item != "")
                {
                    company_names.Add(item);
                }
            }


            List <string> company_addresses = new List <string>();

            foreach (var item in company_address)
            {
                company_addresses.Add(item);
            }


            List <string> roles = new List <string>();

            foreach (var item in role)
            {
                roles.Add(item);
            }


            List <DateTime?> duration_froms = new List <DateTime?>();

            foreach (var item in duration_from)
            {
                duration_froms.Add(item);
            }

            List <DateTime?> duration_tos = new List <DateTime?>();

            foreach (var item in duration_to)
            {
                duration_tos.Add(item);
            }


            if (qualifications.Count > 0)
            {
                resume.EducationalDetails = new List <DegreeDetails>();

                for (int i = 0; i < qualifications.Count; i++)
                {
                    var degree = new DegreeDetails();
                    degree.Grade         = resutls[i];
                    degree.Institute     = Institutes[i];
                    degree.PassingYear   = passing_years[i];
                    degree.Qualification = qualifications[i];
                    degree.Subject       = Subjects[i];
                    resume.EducationalDetails.Add(degree);
                }
            }


            resume.Email = email;


            if (company_names.Count > 0)
            {
                resume.Experiences = new List <ProfessionalExperience>();
                for (int i = 0; i < company_names.Count; i++)
                {
                    var experience = new ProfessionalExperience();
                    experience.CompanyAddress = company_addresses[i];
                    experience.CompanyName    = company_names[i];
                    experience.DurationFrom   = duration_froms[i];
                    experience.DurationTo     = duration_tos[i];
                    experience.Role           = roles[i];
                    resume.Experiences.Add(experience);
                }
            }

            resume.FatherName       = father_name;
            resume.Gender           = gender;
            resume.MarritualStatus  = marritual_status;
            resume.MobileNumber     = mobile_number;
            resume.MotherName       = mother_name;
            resume.NationalID       = national_id;
            resume.Nationality      = nationality;
            resume.PermanentAddress = permanent_address;
            resume.PhoneNumber      = phone_number;
            resume.PresentAddress   = present_address;

            if (profile_img != null)
            {
                using (var memoryStream = new MemoryStream())
                {
                    await profile_img.CopyToAsync(memoryStream);

                    resume.ProfileImage = memoryStream.ToArray();
                    user.ProfileImage   = memoryStream.ToArray();
                    _accountManage.User.ProfileImage    = memoryStream.ToArray();
                    _accountManage.User.ProfileImageSrc = _accountManage.ImgSrc(_accountManage.User.ProfileImage);
                }
            }
            else
            {
                MemoryStream memoryStream      = new MemoryStream();
                var          current_directory = Directory.GetCurrentDirectory();
                FileStream   fileStream        = new FileStream($"{current_directory}/wwwroot/img/user.png", FileMode.Open);
                await fileStream.CopyToAsync(memoryStream);

                resume.ProfileImage = memoryStream.ToArray();
                user.ProfileImage   = memoryStream.ToArray();
                _accountManage.User.ProfileImage    = memoryStream.ToArray();
                _accountManage.User.ProfileImageSrc = _accountManage.ImgSrc(_accountManage.User.ProfileImage);
            }

            resume.Religion = religion;

            user.Resume = resume;

            await _db.SaveChangesAsync();

            var us = _db.Users.Include(u => u.Resume).SingleOrDefault(u => u.Id == _accountManage.User.Id);

            return(RedirectToPage("./ViewCV", new { id = us.Resume.Id }));
        }
        public async Task <IActionResult> OnPostAsync(long id)
        {
            var users = _db.Users.Where(a => a.UserName == Username).ToList();

            if (users != null)
            {
                if (users.Count > 0)
                {
                    UsernameExisted = true;
                    return(Page());
                }
            }

            var user = await _db.Users.FindAsync(id);


            user.UserType    = UserType.Employee;
            user.UserName    = Username.ToLower();
            user.JoiningDate = JoiningDate;

            var appls = await _db.RecruitementNotices.Include(a => a.Applicants).SelectMany(a => a.Applicants).ToListAsync();

            var gg = appls.SingleOrDefault(a => a.Id == user.Id);

            if (gg != null)
            {
                appls.Remove(gg);
            }


            await _db.SaveChangesAsync();



            var uu = await _db.RecruitementNotices.Include(a => a.Applicants).SelectMany(a => a.Applicants).ToListAsync();

            var yy = uu.Find(o => o.Id == user.Id);

            uu.Remove(yy);

            //if (notices != null)
            //{
            //    if (notices.Count > 0)
            //    {
            //        bool done = false;
            //        foreach (var item in notices)
            //        {
            //            UserModel u = null;
            //            foreach (var apl in item.Applicants)
            //            {
            //                if (apl.Id == id)
            //                {
            //                    u = apl;
            //                    done = true;
            //                    break;
            //                }
            //            }
            //            if( u!= null)
            //            {
            //                item.Applicants.Remove(u);
            //                if (done == true)
            //                    break;
            //            }

            //        }
            //    }
            //}
            await _db.SaveChangesAsync();

            return(RedirectToPage("./EmployeeList"));
        }
        public async Task <IActionResult> OnPostAsync()
        {
            if (ModelState.IsValid)
            {
                DepartmentModel  department  = null;
                DesignationModel designation = null;

                if (Department != null)
                {
                    department = await _db.Departments.FindAsync((long)Department);
                }
                if (Designation != null)
                {
                    designation = await _db.Designations.FindAsync((long)Designation);
                }

                if (department == null)
                {
                    return(NotFound());
                }
                if (designation == null)
                {
                    return(NotFound());
                }

                var notice = new RecruitementNoticeModel
                {
                    Title           = Title,
                    Description     = Description,
                    LastDate        = EndDate,
                    Department      = department.Name,
                    Designation     = designation.Name,
                    NumberOfVacancy = NumberOfVacancy,
                    IsPublished     = Published,
                    CreatedDate     = DateTime.Now
                };

                await _db.RecruitementNotices.AddAsync(notice);

                await _db.SaveChangesAsync();

                return(RedirectToPage("./ManageRecruitmentNotice"));
            }

            var departments = await _db.Departments.AsNoTracking().ToListAsync();

            DepartmentList = new List <SelectListItem>();
            if (departments != null)
            {
                if (departments.Count > 0)
                {
                    foreach (var item in departments)
                    {
                        DepartmentList.Add(new SelectListItem {
                            Value = item.Id.ToString(), Text = item.Name
                        });
                    }
                }
            }
            Department = null;
            return(Page());
        }