public ActionResult Create()
 {
     ViewBag.businessUnits = new SelectList(BunitsRepo.GetBusinessUnit().OrderBy(x => x.BusId), "BusId", "unitname", "BusId");
     ViewBag.Months        = new SelectList(Apimanager.GetAllMonths().OrderBy(x => x.id), "MonthId", "MonthName", "MonthId");
     ViewBag.weekDays      = new SelectList(Apimanager.GetWeekDays().OrderByDescending(x => x.id), "id", "DayLongCode", "id");
     return(View());
 }
 public ActionResult Create([Bind(Include = "id,CalStartMonth,WeekendStartDay,WeekendEndDay,BusinessunitId,DepartmentId,HrId,HoursDay,IsHalfday,IsLeaveTransfer,IsSkipHolidays,Descriptions,Isactive")] LeaveManagementViewModel model)
 {
     try
     {
         if (ModelState.IsValid)
         {
             LeaveManagement leave = new LeaveManagement();
             leave.CalStartMonth   = model.CalStartMonth.Value.ToString();
             leave.businessunitId  = model.businessunitId;
             leave.WeekendStartDay = model.WeekendStartDay.Value.ToString();
             leave.WeekendEndDay   = model.WeekendEndDay.Value.ToString();
             leave.IsSkipHolidays  = model.IsSkipHolidays;
             leave.IsLeaveTransfer = model.IsLeaveTransfer;
             leave.departmentId    = model.departmentId;
             leave.Descriptions    = model.Descriptions;
             leave.HoursDay        = model.HoursDay.Value.ToString();
             leave.HrId            = model.HrId;
             leave.createdby       = User.Identity.GetUserId();
             leave.modifiedby      = User.Identity.GetUserId();
             leave.Isactive        = true;
             leaveRepo.AddLeaveManagement(leave);
             return(RedirectToAction("Index"));
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
     ViewBag.businessUnits = new SelectList(BunitsRepo.GetBusinessUnit().OrderBy(x => x.BusId), "BusId", "unitname", "BusId");
     ViewBag.Months        = new SelectList(Apimanager.GetAllMonths().OrderBy(x => x.id), "MonthId", "MonthName", "MonthId");
     ViewBag.weekDays      = new SelectList(Apimanager.GetWeekDays().OrderByDescending(x => x.id), "id", "DayLongCode", "id");
     return(View(model));
 }
Beispiel #3
0
        public async Task <ActionResult> Create(EmployeeViewModel employees, string returnUrl)
        {
            Employees realEmployee    = new Employees();
            var       RealUserId      = employees.identityCode + employees.empUserId;
            var       EmployeeIdExist = Infrastructure.UserManager.checkEmployeeId(RealUserId);

            if (ModelState.IsValid && EmployeeIdExist != true)
            {
                realEmployee.businessunitId    = employees.businessunitId.Value;
                realEmployee.createdby         = null;
                realEmployee.dateOfJoining     = employees.dateOfJoining;
                realEmployee.dateOfLeaving     = employees.dateOfLeaving;
                realEmployee.departmentId      = employees.departmentId.Value;
                realEmployee.empEmail          = employees.empEmail;
                realEmployee.FullName          = employees.FirstName + " " + employees.lastName;
                realEmployee.empStatusId       = employees.empStatusId;
                realEmployee.isactive          = true;
                realEmployee.jobtitleId        = employees.jobtitleId.Value;
                realEmployee.modeofEmployement = employees.modeofEmployement;
                realEmployee.modifiedby        = null;
                realEmployee.officeNumber      = employees.officeNumber;
                realEmployee.positionId        = realEmployee.positionId;
                realEmployee.prefixId          = employees.prefixId;
                realEmployee.yearsExp          = employees.yearsExp;
                realEmployee.isactive          = true;
                var CreatedDate  = realEmployee.createddate = DateTime.Now;
                var modifiedDate = realEmployee.modifieddate = DateTime.Now;
                try
                {
                    var newCreatedUser = await Infrastructure.UserManager.CreateUser(employees.empEmail, employees.empRoleId.ToString(), employees.empStatusId, employees.FirstName, employees.lastName, employees.officeNumber,
                                                                                     RealUserId, employees.jobtitleId.ToString(), null, null, User.Identity.GetUserId(), employees.modeofEmployement.ToString(),
                                                                                     employees.dateOfJoining, null, true, employees.departmentId.ToString(), employees.businessunitId.ToString());

                    if (newCreatedUser.Id != null)
                    {
                        realEmployee.empRoleId = employees.empRoleId;
                        realEmployee.userId    = newCreatedUser.Id;
                        empRepo.addEmployees(realEmployee);
                    }
                }
                catch (Exception ex)
                {
                    throw ex;
                }
                return(Redirect(returnUrl));
            }
            TempData["Error"]     = String.Format($"The employee id already { employees.empUserId} exist in the system");
            ViewBag.EmpStatus     = new SelectList(statusRepo.GetEmployementStatus().Select(x => new { name = x.employemnt_status, id = x.empstId }).OrderBy(x => x.name), "id", "name", "id");
            ViewBag.roles         = new SelectList(GetRoles().OrderBy(x => x.Name).Where(u => !u.Name.Contains("System Admin") && !u.Name.Contains("Management") && !u.Name.Contains("Manager")).Select(x => new { name = x.Name, id = x.Id }), "Id", "name", "Id");
            ViewBag.prefix        = new SelectList(Apimanager.PrefixeList(), "prefixId", "prefixName", "prefixId");
            ViewBag.businessUnits = new SelectList(BunitsRepo.GetBusinessUnit().OrderBy(x => x.BusId), "BusId", "unitname", "BusId");
            ViewBag.jobTitles     = new SelectList(Apimanager.JobList().OrderBy(x => x.JobName), "JobId", "JobName", "JobId");
            return(Redirect(returnUrl));
        }
Beispiel #4
0
        public ActionResult Create(string returnUrl)
        {
            ViewBag.returnUrl = returnUrl;
            var result = statusRepo.GetEmployementStatus().Select(x => new { name = x.employemnt_status, id = x.empstId });

            ViewBag.EmpStatus     = new SelectList(statusRepo.GetEmployementStatus().Select(x => new { name = x.employemnt_status, id = x.empstId }), "id", "name", "id");
            ViewBag.roles         = new SelectList(GetRoles().OrderBy(x => x.Name).Where(u => !u.Name.Contains("System Admin") && !u.Name.Contains("Management")).Select(x => new { name = x.Name, id = x.Id }), "Id", "name", "Id");
            ViewBag.prefix        = new SelectList(Apimanager.PrefixeList(), "prefixId", "prefixName", "prefixId");
            ViewBag.businessUnits = new SelectList(BunitsRepo.GetBusinessUnit().OrderBy(x => x.BusId), "BusId", "unitname", "BusId");
            ViewBag.jobTitles     = new SelectList(Apimanager.JobList().OrderBy(x => x.JobName), "JobId", "JobName", "JobId");
            return(View());
        }
        public IHttpActionResult GetEmployeeAllLeave(string userId)
        {
            if (userId == null)
            {
                return(BadRequest());
            }
            var result = Apimanager.GetEmployeeAllLeave(userId);

            if (result == null)
            {
                return(Ok("No result found"));
            }
            return(Ok(result));
        }
        public IHttpActionResult Jobs()
        {
            var result = Apimanager.JobList();

            if (result == null)
            {
                var emptyResult = new { Message = "No file Found" };
                return(Ok(emptyResult));
            }
            else
            {
                return(Ok(result));
            }
        }
        public IHttpActionResult GetRmByUserId(string userId)
        {
            if (userId == null)
            {
                return(BadRequest());
            }
            var result = Apimanager.GetReportManagrbyUserId(userId);

            if (result == null)
            {
                return(Ok("No result found"));
            }
            return(Ok(result));
        }
        public IHttpActionResult GetEmpByDept(int?id)
        {
            if (id == null)
            {
                return(BadRequest());
            }
            var result = Apimanager.GetEmployeeByDept(id.Value);

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

            else
            {
                return(Ok(result));
            }
        }
        public IHttpActionResult GetempLeaveAmount(int?id)
        {
            if (id == null)
            {
                return(BadRequest());
            }
            var result = Apimanager.LeaveTypeById(id.Value);

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

            else
            {
                return(Ok(result));
            }
        }
        public IHttpActionResult GetempLeaveAmount(string id)
        {
            if (id == null)
            {
                return(BadRequest());
            }
            var result = Apimanager.getEmpLeaveByUserId(id);

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

            else
            {
                return(Ok(result));
            }
        }
        public IHttpActionResult GetRMByBusinessUnit(int?id)
        {
            if (id == null)
            {
                return(BadRequest());
            }
            var result = Apimanager.GetReportManagerBusinessUnit(id.Value);

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

            else
            {
                return(Ok(result));
            }
        }
 public IHttpActionResult DepartmentId(int?id)
 {
     if (id == null)
     {
         return(BadRequest());
     }
     else
     {
         var dept = Apimanager.DepartmentById(id);
         if (dept == null)
         {
             return(NotFound());
         }
         else
         {
             return(Ok(dept));
         }
     }
 }
Beispiel #13
0
 public ActionResult addPosition(Positions model, string returnUrl)
 {
     try
     {
         if (ModelState.IsValid)
         {
             Positions position = model;
             position.createdby    = null; // int.Parse(User.Identity.GetUserId());
             position.modifiedby   = null; //int.Parse(User.Identity.GetUserId());
             position.modifieddate = DateTime.Now;
             positionRepo.AddPosition(position);
             ModelState.Clear();
             TempData["Success"] = string.Format($"{position.positionname} has been created");
             return(Redirect(returnUrl));
         }
         ViewBag.jobTitles = new SelectList(Apimanager.JobList().OrderBy(x => x.JobName), "JobId", "JobName", "JobId");
         TempData["Error"] = "Something went wrong. please make sure you fill all the appropriate details";
         return(PartialView(model));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
 public IHttpActionResult EmployeeCode(int id)
 {
     return(Ok(Apimanager.GetIdntityList()));
 }
 public IHttpActionResult Status()
 {
     return(Ok(Apimanager.empStatusList()));
 }
Beispiel #16
0
 public PartialViewResult addPosition(string returnUrl)
 {
     ViewBag.returnUrl = returnUrl;
     ViewBag.jobTitles = new SelectList(Apimanager.JobList().OrderBy(x => x.JobName), "JobId", "JobName", "JobId");
     return(PartialView(new Positions()));
 }
 public IHttpActionResult Position()
 {
     return(Ok(Apimanager.GetPositionList()));
 }
        public IHttpActionResult PositionById(int id)
        {
            var result = Apimanager.GetPositionById(id);

            return(Ok(result));
        }
 public IHttpActionResult BusinessUnit()
 {
     return(Ok(Apimanager.GetBusinessUnitList()));
 }
 public IHttpActionResult Prefixes()
 {
     return(Ok(Apimanager.PrefixeList()));
 }
 public IHttpActionResult Departments()
 {
     return(Ok(Apimanager.DepartmentList()));
 }