Exemple #1
0
 public async Task <GenericActionResult <UserProfile> > SaveUserDetails(AddUserProfileModel userProfileModel, string webRootPath, string userId)
 {
     try
     {
         if (context.UserProfiles.FirstOrDefault(a => a.UserId.Equals(userId)) != null)
         {
             return(await UpdateUserDetails(ObjectConverterManager.ToUserProfileModel(userProfileModel, userId), webRootPath));
         }
         var userProfile = new UserProfile
         {
             CountryId        = userProfileModel.CountryId,
             DateOfBirth      = userProfileModel.DateOfBirth,
             FirstName        = userProfileModel.FirstName,
             Gender           = (byte)userProfileModel.Gender,
             LastName         = userProfileModel.LastName,
             UserId           = userId,
             DateCreated      = DateTime.Now,
             IsDeleted        = false,
             ProfileImageName = await UploadFile.SaveFileInWebRoot(userProfileModel.ProfileImage, webRootPath)
         };
         context.UserProfiles.Add(userProfile);
         context.SaveChanges();
         return(new GenericActionResult <UserProfile>(true, "User details saved successfully.", userProfile));
     }
     catch (Exception)
     {
         return(new GenericActionResult <UserProfile>("Failed to save user details, please try again or contact the administrator."));
     }
 }
Exemple #2
0
        public async Task <GenericActionResult <Job> > UpdateJob(JobModel jobModel, string webRootPath)
        {
            try
            {
                Job job = context.Jobs.Find(jobModel.Id);
                job.Compensation     = jobModel.Compensation;
                job.Address          = jobModel.Address;
                job.Description      = jobModel.Description;
                job.TalentId         = jobModel.TalentId;
                job.UserId           = jobModel.UserId;
                job.Name             = jobModel.Name;
                job.Disabled         = jobModel.Disabled;
                job.DueDate          = jobModel.DueDate;
                job.Gender           = jobModel.Gender;
                job.CountryId        = jobModel.CountryId;
                job.ProfileImageName = await UploadFile.SaveFileInWebRoot(jobModel.ProfileImage, webRootPath);

                context.SaveChanges();
                return(new GenericActionResult <Job>(true, "Job updated successfully.", job));
            }
            catch (Exception)
            {
                return(new GenericActionResult <Job>("Failed to update job, please try again or contact the administrator."));
            }
        }
Exemple #3
0
 public async Task <GenericActionResult <Job> > SaveJob(AddJobModel jobModel, string webRootPath, string userId)
 {
     try
     {
         var job = new Job {
             Compensation     = jobModel.Compensation,
             DateCreated      = DateTime.Now,
             Address          = jobModel.Address,
             Description      = jobModel.Description,
             TalentId         = jobModel.TalentId,
             UserId           = userId,
             Name             = jobModel.Name,
             Disabled         = false,
             DueDate          = jobModel.DueDate,
             Gender           = jobModel.Gender,
             CountryId        = jobModel.CountryId,
             ProfileImageName = await UploadFile.SaveFileInWebRoot(jobModel.ProfileImage, webRootPath)
         };
         context.Jobs.Add(job);
         context.SaveChanges();
         return(new GenericActionResult <Job>(true, "Job saved successfully.", job));
     }
     catch (Exception)
     {
         return(new GenericActionResult <Job>("Failed to save job, please try again or contact the administrator."));
     }
 }
Exemple #4
0
 public async Task <GenericActionResult <OrganisationProfile> > SaveOrganisationProfile(AddOrganisationProfileModel organisationProfileModel, string webRootPath, string userId)
 {
     try
     {
         if (context.OrganisationProfiles.FirstOrDefault(a => a.UserId.Equals(userId)) != null)
         {
             return(await UpdateOrganisationProfile(ObjectConverterManager.ToOrganisationProfileModel(organisationProfileModel, userId), webRootPath));
         }
         var profile = new OrganisationProfile
         {
             CompanyAddress            = organisationProfileModel.CompanyAddress,
             DateCreated               = DateTime.Now,
             UserId                    = userId,
             BusinessTypeId            = organisationProfileModel.CompanyBusinessType,
             CompanyName               = organisationProfileModel.CompanyName,
             CompanyPhoneNumber        = organisationProfileModel.CompanyPhoneNumber,
             CompanyRegistrationId     = organisationProfileModel.CompanyRegistrationId,
             CountryId                 = organisationProfileModel.CountryId,
             DateOfCompanyRegistration = organisationProfileModel.DateOfCompanyRegistration,
             ProfileImageName          = await UploadFile.SaveFileInWebRoot(organisationProfileModel.ProfileImage, webRootPath)
         };
         context.OrganisationProfiles.Add(profile);
         context.SaveChanges();
         return(new GenericActionResult <OrganisationProfile>(true, "Organisation profile saved successfully.", profile));
     }
     catch (Exception)
     {
         return(new GenericActionResult <OrganisationProfile>("Failed to save organisation profile, please try again or contact the administrator."));
     }
 }
Exemple #5
0
 public async Task <GenericActionResult <UserProfile> > UpdateUserDetails(UserProfileModel userProfileModel, string webRootPath)
 {
     try
     {
         UserProfile userProfile = context.UserProfiles.FirstOrDefault(a => a.UserId.Equals(userProfileModel.UserId));
         if (userProfile != null)
         {
             userProfile.CountryId        = userProfileModel.CountryId;
             userProfile.DateOfBirth      = userProfileModel.DateOfBirth;
             userProfile.FirstName        = userProfileModel.FirstName;
             userProfile.Gender           = (byte)userProfileModel.Gender;
             userProfile.LastName         = userProfileModel.LastName;
             userProfile.ProfileImageName = await UploadFile.SaveFileInWebRoot(userProfileModel.ProfileImage, webRootPath);
         }
         context.SaveChanges();
         return(new GenericActionResult <UserProfile>(true, "User details updated successfully.", userProfile));
     }
     catch (Exception)
     {
         return(new GenericActionResult <UserProfile>("Failed to update user details, please try again or contact the administrator."));
     }
 }
Exemple #6
0
        public async Task <GenericActionResult <OrganisationProfile> > UpdateOrganisationProfile(OrganisationProfileModel organisationProfileModel, string webRootPath)
        {
            try
            {
                OrganisationProfile organisationProfile = context.OrganisationProfiles.Find(organisationProfileModel.Id);
                organisationProfile.CompanyAddress            = organisationProfileModel.CompanyAddress;
                organisationProfile.BusinessTypeId            = organisationProfileModel.CompanyBusinessType;
                organisationProfile.CompanyName               = organisationProfileModel.CompanyName;
                organisationProfile.CompanyPhoneNumber        = organisationProfileModel.CompanyPhoneNumber;
                organisationProfile.CompanyRegistrationId     = organisationProfileModel.CompanyRegistrationId;
                organisationProfile.CountryId                 = organisationProfileModel.CountryId;
                organisationProfile.DateOfCompanyRegistration = organisationProfileModel.DateOfCompanyRegistration;
                organisationProfile.ProfileImageName          = await UploadFile.SaveFileInWebRoot(organisationProfileModel.ProfileImage, webRootPath);

                context.SaveChanges();
                return(new GenericActionResult <OrganisationProfile>(true, "Organisation profile updated successfully.", organisationProfile));
            }
            catch (Exception)
            {
                return(new GenericActionResult <OrganisationProfile>("Failed to update organisation profile, please try again or contact the administrator."));
            }
        }