コード例 #1
0
ファイル: ProfileController.cs プロジェクト: xprasoulas/grid
        public JsonResult AddCertification(AddCertificationViewModel vm)
        {
            var userSkill = new UserCertification
            {
                UserId          = WebUser.Id,
                CertificationId = vm.CertificationId,
            };

            _userCertificationRepository.Create(userSkill);
            _unitOfWork.Commit();

            return(Json(true));
        }
コード例 #2
0
 //Certification
 public IActionResult AddEditUserCertification(int Id)
 {
     CertificationVM vm = new CertificationVM();
     if (Id > 0)
     {
         UserCertification cert = _context.UserCertification.SingleOrDefault(x => x.UserCertificationId == Id);
         vm.Name = cert.Name;
         vm.CertificationDate = cert.CertificationDate;
         vm.ExpirationDate = cert.ExpirationDate;
         vm.LiscenceNo = cert.LiscenceNo;
         vm.URL = cert.URL;
         vm.UserCertificationId = cert.UserCertificationId;
     }
     return PartialView(vm);
 }
コード例 #3
0
        public static bool SaveCertification(string username, UserCertification usercertification)
        {
            try
            {
                using (var context = new DatabaseDataContext())
                {
                    if (usercertification.UserName == null)
                    {
                        usercertification.UserName = username;
                    }
                    var user = context.Users.Single(x => x.UserName == username);
                    if (usercertification.UserName != username)
                    {
                        if (!UserInfo.IsAdmin(context, user))
                        {
                            return(false);
                        }
                    }
                    if (usercertification.ID == 0)
                    {
                        context.UserCertifications.InsertOnSubmit(usercertification);
                    }

                    else
                    {
                        var temp = context.UserCertifications.Single(x => x.ID == usercertification.ID);
                        if (temp.UserName != usercertification.UserName)
                        {
                            throw new Exception();
                        }
                        temp.DataCertificationID = usercertification.DataCertificationID;
                        temp.LicenseNo           = usercertification.LicenseNo;
                        temp.IssuedBy            = usercertification.IssuedBy;
                        temp.IssueDate           = usercertification.IssueDate;
                        temp.Grade                  = usercertification.Grade;
                        temp.Expiration             = usercertification.Expiration;
                        temp.OtherDataCertification = usercertification.OtherDataCertification;
                    }
                    context.SubmitChanges();
                    return(true);
                }
            }
            catch (Exception)
            {
                return(false);
            }
        }
コード例 #4
0
ファイル: UsersController.cs プロジェクト: xprasoulas/grid
        public JsonResult AddCertification(AddCertificationViewModel vm)
        {
            var selectedUser = _userRepository.GetBy(r => r.Id == vm.UserId);

            if (selectedUser != null)
            {
                var userCertification = new UserCertification
                {
                    UserId          = selectedUser.Id,
                    CertificationId = vm.CertificationId
                };

                _userCertificationRepository.Create(userCertification);
                _unitOfWork.Commit();

                return(Json(true));
            }

            return(Json(false));
        }
コード例 #5
0
        public ActionResult addCertification([FromBody] AddCertificationViewModel certificate)
        {
            try
            {
                var newCert = new UserCertification
                {
                    UserId            = _userAppContext.CurrentUserId,
                    Id                = ObjectId.GenerateNewId().ToString(),
                    CertificationName = certificate.CertificationName,
                    CertificationFrom = certificate.CertificationFrom,
                    CertificationYear = certificate.CertificationYear
                };
                _userCertificationRepository.Add(newCert);

                return(Json(new { Success = true, Message = "certificate added succesfully" }));
            }
            catch
            {
                return(Json(new { Success = false, Message = "Error while adding certificate" }));
            }
        }
コード例 #6
0
 public Task DeleteAsync(UserCertification parameters)
 {
     throw new NotImplementedException();
 }
コード例 #7
0
        public ActionResult Update(NewUserViewModel vm)
        {
            ApiResult <User> apiResult;

            if (ModelState.IsValid)
            {
                if (vm.Id > 0)
                {
                    apiResult = TryExecute(() =>
                    {
                        var selectedUser                         = _userRepository.Get(vm.Id, "Person");
                        selectedUser.EmployeeCode                = vm.EmployeeCode;
                        selectedUser.Person.FirstName            = vm.Person.FirstName;
                        selectedUser.Person.MiddleName           = vm.Person.MiddleName;
                        selectedUser.Person.LastName             = vm.Person.LastName;
                        selectedUser.Person.Gender               = vm.Person.Gender;
                        selectedUser.Person.Email                = vm.Person.Email;
                        selectedUser.Person.PhoneNo              = vm.Person.PhoneNo;
                        selectedUser.Person.SecondaryEmail       = vm.Person.SecondaryEmail;
                        selectedUser.Person.Address              = vm.Person.Address;
                        selectedUser.Person.CommunicationAddress = vm.Person.CommunicationAddress;
                        selectedUser.Person.PassportNo           = vm.Person.PassportNo;
                        selectedUser.Person.DateOfBirth          = vm.Person.DateOfBirth;
                        selectedUser.Person.BloodGroup           = vm.Person.BloodGroup;
                        selectedUser.Person.MaritalStatus        = vm.Person.MaritalStatus;
                        selectedUser.Person.MarriageAnniversary  = vm.Person.MarriageAnniversary;
                        selectedUser.DepartmentId                = vm.DepartmentId;
                        selectedUser.LocationId                  = vm.LocationId;
                        selectedUser.DesignationId               = vm.DesignationId;
                        selectedUser.ShiftId                     = vm.ShiftId;
                        selectedUser.ReportingPersonId           = vm.ReportingPersonId;
                        selectedUser.Experience                  = vm.Experience;
                        selectedUser.DateOfJoin                  = vm.DateOfJoin;
                        selectedUser.ConfirmationDate            = vm.ConfirmationDate;
                        selectedUser.DateOfResignation           = vm.DateOfResignation;
                        selectedUser.LastDate                    = vm.LastDate;
                        selectedUser.OfficialEmail               = vm.OfficialEmail;
                        selectedUser.OfficialPhone               = vm.OfficialPhone;
                        selectedUser.OfficialMessengerId         = vm.OfficialMessengerId;
                        selectedUser.EmployeeStatus              = vm.EmployeeStatus;
                        selectedUser.RequiresTimeSheet           = vm.RequiresTimeSheet;
                        selectedUser.Salary                      = vm.Salary;
                        selectedUser.Bank                        = vm.Bank;
                        selectedUser.BankAccountNumber           = vm.BankAccountNumber;
                        selectedUser.PANCard                     = vm.PANCard;
                        selectedUser.PaymentMode                 = vm.PaymentMode;

                        _userRepository.Update(selectedUser);
                        _unitOfWork.Commit();

                        // Remove the existing mapped Roles
                        var existingRoles = _roleMemberRepository.GetAllBy(m => m.UserId == selectedUser.Id);
                        foreach (var map in existingRoles)
                        {
                            _roleMemberRepository.Delete(map);
                        }

                        if (vm.RoleIds != null)
                        {
                            // Map the New Technologies
                            foreach (var roleId in vm.RoleIds)
                            {
                                var newMap = new RoleMember
                                {
                                    UserId = vm.Id,
                                    RoleId = roleId
                                };

                                _roleMemberRepository.Create(newMap);
                            }

                            _unitOfWork.Commit();
                        }

                        // Remove the existing mapped Technologies
                        var existingMaps = _userTechnologyMapRepository.GetAllBy(m => m.UserId == selectedUser.Id);
                        foreach (var map in existingMaps)
                        {
                            _userTechnologyMapRepository.Delete(map);
                        }

                        _unitOfWork.Commit();

                        if (vm.TechnologyIds != null)
                        {
                            // Map the New Technologies
                            foreach (var technologyId in vm.TechnologyIds)
                            {
                                var newMap = new UserTechnologyMap
                                {
                                    UserId       = vm.Id,
                                    TechnologyId = technologyId
                                };

                                _userTechnologyMapRepository.Create(newMap);
                            }

                            _unitOfWork.Commit();
                        }


                        // Remove the existing mapped Skills
                        var existingSkillMaps = _userSkillRepository.GetAllBy(m => m.UserId == selectedUser.Id);
                        foreach (var map in existingSkillMaps)
                        {
                            _userSkillRepository.Delete(map);
                        }

                        _unitOfWork.Commit();

                        if (vm.SkillIds != null)
                        {
                            // Map the New Technologies
                            foreach (var skillId in vm.SkillIds)
                            {
                                var newMap = new UserSkill
                                {
                                    UserId  = vm.Id,
                                    SkillId = skillId
                                };

                                _userSkillRepository.Create(newMap);
                            }

                            _unitOfWork.Commit();
                        }

                        // Remove the existing mapped Skills
                        var existingHobbyMaps = _userHobbyRepository.GetAllBy(m => m.UserId == selectedUser.Id);
                        foreach (var map in existingHobbyMaps)
                        {
                            _userHobbyRepository.Delete(map);
                        }

                        _unitOfWork.Commit();

                        if (vm.HobbiesId != null)
                        {
                            // Map the New Technologies
                            foreach (var hobbyId in vm.HobbiesId)
                            {
                                var newMap = new UserHobby
                                {
                                    UserId  = vm.Id,
                                    HobbyId = hobbyId
                                };

                                _userHobbyRepository.Create(newMap);
                            }

                            _unitOfWork.Commit();
                        }

                        // Remove the existing mapped Certifications
                        var existingCertificationMaps =
                            _userCertificationRepository.GetAllBy(m => m.UserId == selectedUser.Id);
                        foreach (var map in existingCertificationMaps)
                        {
                            _userCertificationRepository.Delete(map);
                        }

                        _unitOfWork.Commit();

                        if (vm.CertificationIds != null)
                        {
                            // Map the New Technologies
                            foreach (var certificateId in vm.CertificationIds)
                            {
                                var newMap = new UserCertification
                                {
                                    UserId          = vm.Id,
                                    CertificationId = certificateId
                                };

                                _userCertificationRepository.Create(newMap);
                            }

                            _unitOfWork.Commit();
                        }

                        return(selectedUser);
                    }, "User updated sucessfully");
                }
                else
                {
                    apiResult = TryExecute(() =>
                    {
                        var newUser = new User
                        {
                            EmployeeCode        = vm.EmployeeCode,
                            Username            = vm.Username,
                            Password            = HashHelper.Hash(vm.Password),
                            AccessRule          = AccessRule.CreateNewUserAccessRule(true),
                            Person              = vm.Person,
                            DepartmentId        = vm.DepartmentId,
                            LocationId          = vm.LocationId,
                            DesignationId       = vm.DesignationId,
                            ShiftId             = vm.ShiftId,
                            ReportingPersonId   = vm.ReportingPersonId,
                            Experience          = vm.Experience,
                            DateOfJoin          = vm.DateOfJoin,
                            ConfirmationDate    = vm.ConfirmationDate,
                            DateOfResignation   = vm.DateOfResignation,
                            LastDate            = vm.LastDate,
                            OfficialEmail       = vm.OfficialEmail,
                            OfficialPhone       = vm.OfficialPhone,
                            OfficialMessengerId = vm.OfficialMessengerId,
                            EmployeeStatus      = vm.EmployeeStatus,
                            RequiresTimeSheet   = vm.RequiresTimeSheet,
                            Salary              = vm.Salary,
                            Bank = vm.Bank,
                            BankAccountNumber = vm.BankAccountNumber,
                            PANCard           = vm.PANCard,
                            PaymentMode       = vm.PaymentMode
                        };

                        _userRepository.Create(newUser);
                        _unitOfWork.Commit();

                        // Map the Technologies
                        if (vm.TechnologyIds != null)
                        {
                            foreach (var technologyId in vm.TechnologyIds)
                            {
                                var newMap = new UserTechnologyMap
                                {
                                    UserId       = newUser.Id,
                                    TechnologyId = technologyId
                                };
                                _userTechnologyMapRepository.Create(newMap);
                            }

                            _unitOfWork.Commit();
                        }


                        // Map the Technologies
                        if (vm.RoleIds != null)
                        {
                            foreach (var roleId in vm.RoleIds)
                            {
                                var newMap = new RoleMember
                                {
                                    UserId = newUser.Id,
                                    RoleId = roleId
                                };

                                _roleMemberRepository.Create(newMap);
                            }

                            _unitOfWork.Commit();
                        }

                        return(newUser);
                    }, "User created sucessfully");
                }
            }
            else
            {
                apiResult = ApiResultFromModelErrors <User>();
            }

            return(Json(apiResult, JsonRequestBehavior.AllowGet));
        }
コード例 #8
0
        public async Task UpdateAsync(UserCertification entity)
        {
            await Uow.RegisterDirtyAsync(entity);

            await Uow.CommitAsync();
        }
コード例 #9
0
 public HashSet <string> DeleteValidation(UserCertification parameters)
 {
     return(ValidationMessages);
 }
コード例 #10
0
        public async Task AddAsync(UserCertification entity)
        {
            await Uow.RegisterNewAsync(entity);

            await Uow.CommitAsync();
        }
コード例 #11
0
 public HashSet <string> UpdateValidation(UserCertification entity)
 {
     return(ValidationMessages);
 }
コード例 #12
0
ファイル: UsersController.cs プロジェクト: xprasoulas/grid
        public ActionResult Edit(EditUserViewModel vm)
        {
            var selectedUser = _userRepository.Get(vm.Id, "Person");

            if (selectedUser != null)
            {
                selectedUser.EmployeeCode                = vm.EmployeeCode;
                selectedUser.Person.FirstName            = vm.Person.FirstName;
                selectedUser.Person.MiddleName           = vm.Person.MiddleName;
                selectedUser.Person.LastName             = vm.Person.LastName;
                selectedUser.Person.Gender               = vm.Person.Gender;
                selectedUser.Person.Email                = vm.Person.Email;
                selectedUser.Person.PhoneNo              = vm.Person.PhoneNo;
                selectedUser.Person.SecondaryEmail       = vm.Person.SecondaryEmail;
                selectedUser.Person.Address              = vm.Person.Address;
                selectedUser.Person.CommunicationAddress = vm.Person.CommunicationAddress;
                selectedUser.Person.PassportNo           = vm.Person.PassportNo;
                selectedUser.Person.DateOfBirth          = vm.Person.DateOfBirth;
                selectedUser.Person.BloodGroup           = vm.Person.BloodGroup;
                selectedUser.Person.MaritalStatus        = vm.Person.MaritalStatus;
                selectedUser.Person.MarriageAnniversary  = vm.Person.MarriageAnniversary;
                selectedUser.DepartmentId                = vm.DepartmentId;
                selectedUser.LocationId          = vm.LocationId;
                selectedUser.DesignationId       = vm.DesignationId;
                selectedUser.ShiftId             = vm.ShiftId;
                selectedUser.ReportingPersonId   = vm.ReportingPersonId;
                selectedUser.ManagerId           = vm.ManagerId;
                selectedUser.Experience          = vm.Experience;
                selectedUser.DateOfJoin          = vm.DateOfJoin;
                selectedUser.ConfirmationDate    = vm.ConfirmationDate;
                selectedUser.DateOfResignation   = vm.DateOfResignation;
                selectedUser.LastDate            = vm.LastDate;
                selectedUser.OfficialEmail       = vm.OfficialEmail;
                selectedUser.OfficialPhone       = vm.OfficialPhone;
                selectedUser.OfficialMessengerId = vm.OfficialMessengerId;
                selectedUser.EmployeeStatus      = vm.EmployeeStatus;
                selectedUser.RequiresTimeSheet   = vm.RequiresTimeSheet;
                selectedUser.Salary            = vm.Salary;
                selectedUser.Bank              = vm.Bank;
                selectedUser.BankAccountNumber = vm.BankAccountNumber;
                selectedUser.PANCard           = vm.PANCard;
                selectedUser.PaymentMode       = vm.PaymentMode;

                _userRepository.Update(selectedUser);
                _unitOfWork.Commit();

                // Remove the existing mapped Roles
                var existingRoles = _roleMemberRepository.GetAllBy(m => m.UserId == selectedUser.Id);
                foreach (var map in existingRoles)
                {
                    _roleMemberRepository.Delete(map);
                }

                if (vm.RoleIds != null)
                {
                    //  Map the New Technologies
                    foreach (var roleId in vm.RoleIds)
                    {
                        var newMap = new RoleMember
                        {
                            UserId = vm.Id,
                            RoleId = roleId
                        };

                        _roleMemberRepository.Create(newMap);
                    }

                    _unitOfWork.Commit();
                }

                // Remove the existing mapped Technologies
                var existingMaps = _userTechnologyMapRepository.GetAllBy(m => m.UserId == selectedUser.Id);
                foreach (var map in existingMaps)
                {
                    _userTechnologyMapRepository.Delete(map);
                }

                _unitOfWork.Commit();

                if (vm.TechnologyIds != null)
                {
                    // Map the New Technologies
                    foreach (var technologyId in vm.TechnologyIds)
                    {
                        var newMap = new UserTechnologyMap
                        {
                            UserId       = vm.Id,
                            TechnologyId = technologyId
                        };

                        _userTechnologyMapRepository.Create(newMap);
                    }

                    _unitOfWork.Commit();
                }


                // Remove the existing mapped Skills
                var existingSkillMaps = _userSkillRepository.GetAllBy(m => m.UserId == selectedUser.Id);
                foreach (var map in existingSkillMaps)
                {
                    _userSkillRepository.Delete(map);
                }

                _unitOfWork.Commit();

                if (vm.SkillIds != null)
                {
                    // Map the New Technologies
                    foreach (var skillId in vm.SkillIds)
                    {
                        var newMap = new UserSkill
                        {
                            UserId  = vm.Id,
                            SkillId = skillId
                        };

                        _userSkillRepository.Create(newMap);
                    }

                    _unitOfWork.Commit();
                }

                // Remove the existing mapped Skills
                var existingHobbyMaps = _userHobbyRepository.GetAllBy(m => m.UserId == selectedUser.Id);
                foreach (var map in existingHobbyMaps)
                {
                    _userHobbyRepository.Delete(map);
                }

                _unitOfWork.Commit();

                if (vm.HobbiesId != null)
                {
                    // Map the New Technologies
                    foreach (var hobbyId in vm.HobbiesId)
                    {
                        var newMap = new UserHobby
                        {
                            UserId  = vm.Id,
                            HobbyId = hobbyId
                        };

                        _userHobbyRepository.Create(newMap);
                    }

                    _unitOfWork.Commit();
                }

                // Remove the existing mapped Certifications
                var existingCertificationMaps = _userCertificationRepository.GetAllBy(m => m.UserId == selectedUser.Id);
                foreach (var map in existingCertificationMaps)
                {
                    _userCertificationRepository.Delete(map);
                }

                _unitOfWork.Commit();

                if (vm.CertificationIds != null)
                {
                    // Map the New Technologies
                    foreach (var certificateId in vm.CertificationIds)
                    {
                        var newMap = new UserCertification
                        {
                            UserId          = vm.Id,
                            CertificationId = certificateId
                        };

                        _userCertificationRepository.Create(newMap);
                    }

                    _unitOfWork.Commit();
                }

                return(RedirectToAction("Index"));
            }

            var allErrors = ModelState.Values.SelectMany(v => v.Errors);

            ViewBag.Roles             = new MultiSelectList(_roleRepository.GetAll(), "Id", "Name", vm.RoleIds);
            ViewBag.DepartmentId      = new SelectList(_departmentRepository.GetAll(), "Id", "Title", vm.DepartmentId);
            ViewBag.DesignationId     = new SelectList(_designationRepository.GetAllBy(d => d.DepartmentId == vm.DepartmentId), "Id", "Title", vm.DesignationId);
            ViewBag.LocationId        = new SelectList(_locationRepository.GetAll(), "Id", "Title", vm.LocationId);
            ViewBag.ReportingPersonId = new SelectList(_userRepository.GetAllBy(u => u.EmployeeStatus != EmployeeStatus.Ex && u.Id != 1, "Person"), "Id", "Person.Name", vm.ReportingPersonId);
            ViewBag.ManagerId         = new SelectList(_userRepository.GetAllBy(u => u.EmployeeStatus != EmployeeStatus.Ex && u.Id != 1, "Person"), "Id", "Person.Name", vm.ManagerId);
            ViewBag.ShiftId           = new SelectList(_shiftRepository.GetAll(), "Id", "Title", vm.ShiftId);
            return(View(vm));
        }
コード例 #13
0
        public async Task <object> GetBy(UserCertification parameters)
        {
            return(await Uow.Repository <UserCertification>().FindByAsync(t => (t.UserId == parameters.UserId || t.UserCertificationId == parameters.UserCertificationId)));

            //throw new NotImplementedException();
        }
コード例 #14
0
        public async Task <bool> UpdateTalentProfile(TalentProfileViewModel model, string updaterId)
        {
            try
            {
                if (model.Id != null)
                {
                    User existingTalent = (await _userRepository.GetByIdAsync(model.Id));



                    existingTalent.FirstName        = model.FirstName;
                    existingTalent.MiddleName       = model.MiddleName;
                    existingTalent.LastName         = model.LastName;
                    existingTalent.Gender           = model.Gender;
                    existingTalent.Email            = model.Email;
                    existingTalent.Phone            = model.Phone;
                    existingTalent.MobilePhone      = model.MobilePhone;
                    existingTalent.Address          = model.Address;
                    existingTalent.Nationality      = model.Nationality;
                    existingTalent.Description      = model.Description;
                    existingTalent.VisaStatus       = model.VisaStatus;
                    existingTalent.VisaExpiryDate   = model.VisaExpiryDate;
                    existingTalent.CvName           = model.CvName;
                    existingTalent.Summary          = model.Summary;
                    existingTalent.Description      = model.Description;
                    existingTalent.ProfilePhoto     = model.ProfilePhoto;
                    existingTalent.ProfilePhotoUrl  = model.ProfilePhotoUrl;
                    existingTalent.VideoName        = model.VideoName;
                    existingTalent.LinkedAccounts   = model.LinkedAccounts;
                    existingTalent.JobSeekingStatus = model.JobSeekingStatus;
                    existingTalent.UpdatedBy        = updaterId;
                    existingTalent.UpdatedOn        = DateTime.Now;

                    var newSkills = new List <UserSkill>();
                    foreach (var item in model.Skills)
                    {
                        var skill = existingTalent.Skills.SingleOrDefault(x => x.Id == item.Id);
                        if (skill == null)
                        {
                            skill = new UserSkill
                            {
                                Id        = ObjectId.GenerateNewId().ToString(),
                                IsDeleted = false
                            };
                        }
                        UpdateSkillFromView(item, skill);
                        newSkills.Add(skill);
                    }
                    existingTalent.Skills = newSkills;


                    var newLanguage = new List <UserLanguage>();
                    foreach (var item in model.Languages)
                    {
                        var language = existingTalent.Languages.SingleOrDefault(x => x.Id == item.Id);

                        if (language == null)
                        {
                            language = new UserLanguage
                            {
                                Id        = ObjectId.GenerateNewId().ToString(),
                                IsDeleted = false
                            };
                        }
                        UpdateLanguageFromView(item, language);
                        newLanguage.Add(language);
                    }
                    existingTalent.Languages = newLanguage;


                    var newEducation = new List <UserEducation>();
                    foreach (var item in model.Education)
                    {
                        var education = existingTalent.Education.SingleOrDefault(x => x.Id == item.Id);
                        if (education == null)
                        {
                            education = new UserEducation
                            {
                                Id        = ObjectId.GenerateNewId().ToString(),
                                IsDeleted = false
                            };
                        }
                        UpdateEducationFromView(item, education);
                        newEducation.Add(education);
                    }
                    existingTalent.Education = newEducation;



                    var newCertifications = new List <UserCertification>();
                    foreach (var item in model.Certifications)
                    {
                        var certifications = existingTalent.Certifications.SingleOrDefault(x => x.Id == item.Id);
                        if (certifications == null)
                        {
                            certifications = new UserCertification
                            {
                                Id        = ObjectId.GenerateNewId().ToString(),
                                IsDeleted = false
                            };
                        }
                        UpdateCertificationFromView(item, certifications);
                        newCertifications.Add(certifications);
                    }
                    existingTalent.Certifications = newCertifications;

                    var newExperience = new List <UserExperience>();
                    foreach (var item in model.Experience)
                    {
                        var experience = existingTalent.Experience.SingleOrDefault(x => x.Id == item.Id);
                        if (experience == null)
                        {
                            experience = new UserExperience
                            {
                                Id = ObjectId.GenerateNewId().ToString(),
                            };
                        }
                        UpdateExperienceFromView(item, experience);
                        newExperience.Add(experience);
                    }
                    existingTalent.Experience = newExperience;


                    await _userRepository.Update(existingTalent);
                }
                return(true);
            }
            catch (MongoException e)
            {
                return(false);
            }
        }
コード例 #15
0
 public void Add(UserCertification entity)
 {
     _context.UserCertification.Add(entity);
     _context.SaveChanges();
 }
コード例 #16
0
 protected AddCertificationViewModel ViewModelFromCertification(UserCertification certification)
 {
     throw new NotImplementedException();
 }
コード例 #17
0
        public async Task <bool> UpdateTalentProfile(TalentProfileViewModel model, string updaterId)
        {
            //swati start

            try
            {
                if (model.Id != null)
                {
                    User existingUser = (await _userRepository.GetByIdAsync(model.Id));
                    existingUser.Email          = model.Email;
                    existingUser.LastName       = model.LastName;
                    existingUser.FirstName      = model.FirstName;
                    existingUser.Phone          = model.Phone;
                    existingUser.Address        = model.Address;
                    existingUser.Nationality    = model.Nationality;
                    existingUser.LinkedAccounts = model.LinkedAccounts;
                    existingUser.Description    = model.Description;
                    existingUser.UpdatedBy      = updaterId;
                    existingUser.UpdatedOn      = DateTime.Now;
                    // existingUser.ProfilePhoto = model.ProfilePhoto;
                    // existingUser.ProfilePhotoUrl = model.ProfilePhotoUrl;
                    existingUser.JobSeekingStatus = model.JobSeekingStatus;
                    existingUser.Summary          = model.Summary;
                    existingUser.VisaStatus       = model.VisaStatus;
                    existingUser.VisaExpiryDate   = model.VisaExpiryDate;

                    if (model.Languages != null)
                    {
                        var newLanguage = new List <UserLanguage>();
                        foreach (var item in model.Languages)
                        {
                            //var lang = existingUser.Languages.SingleOrDefault(x => x.Id == item.Id);
                            //if (lang == null)
                            var lang = new UserLanguage
                            {
                                //  Id = ObjectId.GenerateNewId().ToString(),
                                Id            = item.Id,
                                UserId        = existingUser.Id,
                                LanguageLevel = item.Level,
                                Language      = item.Name
                            };
                            UpdateLanguageFromView(item, lang);
                            newLanguage.Add(lang);
                        }

                        existingUser.Languages = newLanguage;
                    }

                    if (model.Skills != null)
                    {
                        var newSkills = new List <UserSkill>();
                        foreach (var item in model.Skills)
                        {
                            var skill = new UserSkill
                            {
                                Id              = item.Id,
                                UserId          = existingUser.Id,
                                ExperienceLevel = item.Level,
                                Skill           = item.Name
                            };
                            UpdateSkillFromView(item, skill);
                            newSkills.Add(skill);
                        }
                        existingUser.Skills = newSkills;
                    }

                    if (model.Certifications != null)
                    {
                        var newCert = new List <UserCertification>();
                        foreach (var item in model.Certifications)
                        {
                            var cert = new UserCertification
                            {
                                Id     = item.Id,
                                UserId = existingUser.Id
                            };
                            UpdateCertificateFromView(item, cert);
                            newCert.Add(cert);
                        }

                        existingUser.Certifications = newCert;
                    }
                    if (model.Experience != null)
                    {
                        var newExp = new List <UserExperience>();
                        foreach (var item in model.Experience)
                        {
                            var exp = new UserExperience();
                            UpdateExperienceFromView(item, exp);
                            newExp.Add(exp);
                        }
                        existingUser.Experience = newExp;
                    }

                    await _userRepository.Update(existingUser);

                    return(true);
                }
                return(false);
            }
            catch (MongoException e)
            {
                return(false);
            }
        }
コード例 #18
0
ファイル: ProfileController.cs プロジェクト: xprasoulas/grid
        public ActionResult Edit(EditUserViewModel vm)
        {
            var selectedUser = _userRepository.GetBy(u => u.Id == WebUser.Id, "Person");

            if (selectedUser != null)
            {
                selectedUser.Person.FirstName            = vm.Person.FirstName;
                selectedUser.Person.MiddleName           = vm.Person.MiddleName;
                selectedUser.Person.LastName             = vm.Person.LastName;
                selectedUser.Person.Gender               = vm.Person.Gender;
                selectedUser.Person.Email                = vm.Person.Email;
                selectedUser.Person.SecondaryEmail       = vm.Person.SecondaryEmail;
                selectedUser.Person.PhoneNo              = vm.Person.PhoneNo;
                selectedUser.Person.OfficePhone          = vm.Person.OfficePhone;
                selectedUser.Person.Website              = vm.Person.Website;
                selectedUser.Person.Skype                = vm.Person.Skype;
                selectedUser.Person.Facebook             = vm.Person.Facebook;
                selectedUser.Person.Twitter              = vm.Person.Twitter;
                selectedUser.Person.GooglePlus           = vm.Person.GooglePlus;
                selectedUser.Person.LinkedIn             = vm.Person.LinkedIn;
                selectedUser.Person.City                 = vm.Person.City;
                selectedUser.Person.Country              = vm.Person.Country;
                selectedUser.Person.Address              = vm.Person.Address;
                selectedUser.Person.CommunicationAddress = vm.Person.CommunicationAddress;
                selectedUser.Person.PassportNo           = vm.Person.PassportNo;
                selectedUser.Person.DateOfBirth          = vm.Person.DateOfBirth;
                selectedUser.Person.BloodGroup           = vm.Person.BloodGroup;
                selectedUser.Person.MaritalStatus        = vm.Person.MaritalStatus;
                selectedUser.Person.MarriageAnniversary  = vm.Person.MarriageAnniversary;
                selectedUser.OfficialPhone               = vm.OfficialPhone;

                _userRepository.Update(selectedUser);
                _unitOfWork.Commit();

                // Remove the existing mapped Technologies
                var existingMaps = _userTechnologyMapRepository.GetAllBy(m => m.UserId == selectedUser.Id);
                foreach (var map in existingMaps)
                {
                    _userTechnologyMapRepository.Delete(map);
                }

                _unitOfWork.Commit();

                if (vm.TechnologyIds != null)
                {
                    // Map the New Technologies
                    foreach (var technologyId in vm.TechnologyIds)
                    {
                        var newMap = new UserTechnologyMap
                        {
                            UserId       = vm.Id,
                            TechnologyId = technologyId
                        };

                        _userTechnologyMapRepository.Create(newMap);
                    }

                    _unitOfWork.Commit();
                }


                // Remove the existing mapped Skills
                var existingSkillMaps = _userSkillRepository.GetAllBy(m => m.UserId == selectedUser.Id).ToList();
                foreach (var map in existingSkillMaps)
                {
                    _userSkillRepository.Delete(map);
                }

                _unitOfWork.Commit();

                if (vm.SkillIds != null)
                {
                    // Map the New Technologies
                    foreach (var skillId in vm.SkillIds)
                    {
                        var newMap = new UserSkill
                        {
                            UserId  = vm.Id,
                            SkillId = skillId
                        };

                        _userSkillRepository.Create(newMap);
                    }

                    _unitOfWork.Commit();
                }

                // Remove the existing mapped Skills
                var existingHobbyMaps = _userHobbyRepository.GetAllBy(m => m.UserId == selectedUser.Id);
                foreach (var map in existingHobbyMaps)
                {
                    _userHobbyRepository.Delete(map);
                }

                _unitOfWork.Commit();

                if (vm.HobbiesId != null)
                {
                    // Map the New Technologies
                    foreach (var hobbyId in vm.HobbiesId)
                    {
                        var newMap = new UserHobby
                        {
                            UserId  = vm.Id,
                            HobbyId = hobbyId
                        };

                        _userHobbyRepository.Create(newMap);
                    }

                    _unitOfWork.Commit();
                }

                // Remove the existing mapped Certifications
                var existingCertificationMaps = _userCertificationRepository.GetAllBy(m => m.UserId == selectedUser.Id);
                foreach (var map in existingCertificationMaps)
                {
                    _userCertificationRepository.Delete(map);
                }

                _unitOfWork.Commit();

                if (vm.CertificationIds != null)
                {
                    // Map the New Technologies
                    foreach (var certificateId in vm.CertificationIds)
                    {
                        var newMap = new UserCertification
                        {
                            UserId          = vm.Id,
                            CertificationId = certificateId
                        };

                        _userCertificationRepository.Create(newMap);
                    }

                    _unitOfWork.Commit();
                }
                return(RedirectToAction("Index"));
            }

            return(View(vm));
        }
コード例 #19
0
 protected void UpdateCertificationFromView(AddCertificationViewModel model, UserCertification original)
 {
     original.CertificationYear = model.CertificationYear;
     original.CertificationFrom = model.CertificationFrom;
     original.CertificationName = model.CertificationName;
 }
コード例 #20
0
 public Task <object> GetAsync(UserCertification parameters)
 {
     throw new NotImplementedException();
 }