Ejemplo n.º 1
0
        public IActionResult Post(AddOrganisationProfileModel organisationDetailsModel)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            var result = new OrganisationProfileManager(context, userManager).SaveOrganisationProfile(organisationDetailsModel, hostingEnvironment.WebRootPath, User.FindFirst(ClaimTypes.NameIdentifier).Value).Result;

            return(Ok(new { success = result.Success, message = result.Message, data = result.Data }));
        }
 public static OrganisationProfileModel ToOrganisationProfileModel(AddOrganisationProfileModel organisationProfileModel, string userId)
 {
     return(new OrganisationProfileModel
     {
         CompanyAddress = organisationProfileModel.CompanyAddress,
         CompanyBusinessType = organisationProfileModel.CompanyBusinessType,
         CompanyName = organisationProfileModel.CompanyName,
         CompanyPhoneNumber = organisationProfileModel.CompanyPhoneNumber,
         CompanyRegistrationId = organisationProfileModel.CompanyRegistrationId,
         CountryId = organisationProfileModel.CountryId,
         DateOfCompanyRegistration = organisationProfileModel.DateOfCompanyRegistration,
         ProfileImage = organisationProfileModel.ProfileImage,
         UserId = userId
     });
 }
Ejemplo n.º 3
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."));
     }
 }