Exemplo n.º 1
0
        public ActionResult Register(string mode, string id)
        {
            Models.UserViewModel uvModel = new Models.UserViewModel();
            uvModel.MODE          = mode;
            uvModel.DisabledClass = string.Empty;
            if (string.Equals(mode, "EDIT", StringComparison.OrdinalIgnoreCase) || string.Equals(mode, "VIEW", StringComparison.OrdinalIgnoreCase))
            {
                uvModel.UserMasterId = int.Parse(id);
            }
            if (string.Equals(mode, "VIEW", StringComparison.OrdinalIgnoreCase))
            {
                uvModel.DisabledClass = "disabledPlace";
            }
            if (mode != null && string.Equals(mode, "EDIT", StringComparison.OrdinalIgnoreCase) || string.Equals(mode, "VIEW", StringComparison.OrdinalIgnoreCase))
            {
                //Populate edit data using id passed in URL, if id==null then show error message
                StatusDTO <UserMasterDTO> dto = _userSvc.Select(Convert.ToInt32(id));
                uvModel.UserMasterId = dto.ReturnObj.UserMasterId;
                //uvModel.UserMasterId = dto.ReturnObj.UserMasterId;
                uvModel.FName                 = dto.ReturnObj.FName;
                uvModel.MName                 = dto.ReturnObj.MName;
                uvModel.LName                 = dto.ReturnObj.LName;
                uvModel.Gender                = dto.ReturnObj.Gender;
                uvModel.Image                 = dto.ReturnObj.Image;
                uvModel.DOB                   = dto.ReturnObj.DOB;
                uvModel.DOBString             = uvModel.DOB.HasValue ? uvModel.DOB.Value.ToString("dd-MMM-yyyy") : string.Empty;
                uvModel.EmailId               = dto.ReturnObj.EmailId;
                uvModel.ResidentialAddress    = dto.ReturnObj.ResidentialAddress;
                uvModel.PermanentAddress      = dto.ReturnObj.PermanentAddress;
                uvModel.ContactNo             = dto.ReturnObj.ContactNo;
                uvModel.AltContactNo          = dto.ReturnObj.AltContactNo;
                uvModel.BloodGroup            = dto.ReturnObj.BloodGroup;
                uvModel.Location              = dto.ReturnObj.Location;
                uvModel.Role                  = dto.ReturnObj.Role;
                uvModel.UserEntitlementList   = _userSvc.GetUserEntitlement(dto.ReturnObj.UserMasterId);
                uvModel.SelectUserEntitlement = _ddlRepo.GetUserRole();
                uvModel.Subject               = _ddlRepo.Subject();

                uvModel.Employee = new EmployeeDetailsDTO();
                if (dto.ReturnObj.Employee != null)
                {
                    uvModel.Employee.EmployeeId = dto.ReturnObj.Employee.EmployeeId;
                    uvModel.hdnEmployeeId       = dto.ReturnObj.Employee.EmployeeId;
                    uvModel.Employee.EducationalQualification = dto.ReturnObj.Employee.EducationalQualification;
                    uvModel.Employee.DateOfJoining            = dto.ReturnObj.Employee.DateOfJoining;

                    uvModel.DOJString = uvModel.Employee.DateOfJoining.HasValue ? uvModel.Employee.DateOfJoining.Value.ToString("dd-MMM-yyyy") : string.Empty;

                    uvModel.Employee.StaffEmployeeId = dto.ReturnObj.Employee.StaffEmployeeId;
                    uvModel.Employee.Department      = dto.ReturnObj.Employee.Department;
                    uvModel.Employee.Designation     = dto.ReturnObj.Employee.Designation;

                    uvModel.FacultyCourseList = _userSvc.GetFacultyCourseMap(dto.ReturnObj.Employee.EmployeeId);
                    if (dto.ReturnObj.Employee.ClassType != null)
                    {
                        uvModel.Employee.ClassType = dto.ReturnObj.Employee.ClassType;
                    }

                    string employeeImageFolder = _configSvc.GetEmployeeImagesFolder();

                    uvModel.employeeimagepath = _configSvc.GetEmployeeImagesRelPath() + "/" + GetImageFileName(uvModel.Employee.StaffEmployeeId, employeeImageFolder);
                    //if(dto.ReturnObj.Employee.ClassType != null)
                    //{
                    //    uvModel.Employee.Subject = dto.ReturnObj.Employee.Subject;
                    //}
                }
            }

            uvModel.GenderList            = _uiddlRepo.getGenderDropDown();
            uvModel.LocationList          = _uiddlRepo.getLocationDropDown();
            uvModel.RoleList              = _uiddlRepo.getRoleDropDown();
            uvModel.DepartmentList        = _uiddlRepo.getDepartmentDropDown();
            uvModel.DesignationList       = _uiddlRepo.getDesignationDropDown();
            uvModel.SelectUserEntitlement = _ddlRepo.GetUserRole();
            uvModel.ClassTypeList         = _uiddlRepo.getClassTypeDropDown();
            //uvModel.SubjectList = _uiddlRepo.getSubjectDropDown();

            return(View(uvModel));
        }