public CompanyProfileCustom GetCompanyProfile(long companyId)
        {
            try
            {
                var comProfile = cpRep.GetOperation()
                                   .Include(cp => cp.ContactDetails)
                                   .Filter(cp => cp.Companies.Id== companyId)
                                   .Get().FirstOrDefault();
                var comProfileObj = new CompanyProfile
                {
                    Id = comProfile.Id,
                    BusinessName=comProfile.BusinessName,
                    Vision=comProfile.Vision,
                    TurnOver=comProfile.TurnOver,
                    Objectives=comProfile.Objectives,
                    Mission=comProfile.Mission,
                    Experties=comProfile.Experties,
                    Activities=comProfile.Activities,
                    Markets=comProfile.Markets,
                    PreviousWork=comProfile.PreviousWork,
                    Address=comProfile.Address,
                    Location=comProfile.Location,
                    Email=comProfile.Email,
                    ImageLocation=comProfile.ImageLocation

                };
                var comProfileCustom = new CompanyProfileCustom();
                comProfileCustom.companyProfile = comProfileObj;

                if (comProfile.ContactDetails.Count < 1)
                {
                    return null;
                }
                foreach (var oo in comProfile.ContactDetails)
                {
                    if (oo.FieldName == "Phone")
                        comProfileCustom.Phone = GetContactObject(oo);
                    else if (oo.FieldName == "Fax")
                        comProfileCustom.Fax = GetContactObject(oo);
                    else if (oo.FieldName == "Website")
                        comProfileCustom.Website = GetContactObject(oo);
                    else if (oo.FieldName == "Facebook")
                        comProfileCustom.Facebook = GetContactObject(oo);
                    else if (oo.FieldName == "Twitter")
                        comProfileCustom.Twitter = GetContactObject(oo);
                    else if (oo.FieldName == "Google")
                        comProfileCustom.Google = GetContactObject(oo);
                    else if (oo.FieldName == "LinkedIn")
                        comProfileCustom.LinkedIn = GetContactObject(oo);
                    else if (oo.FieldName == "Skype")
                        comProfileCustom.Skype = GetContactObject(oo);
                }
                return comProfileCustom;
            }
            catch (Exception ex)
            {
                return null;
            }
        }
Beispiel #2
0
 public CompanyProfileCustom(CompanyProfile companyProfile)
 {
     Phone = new ContactDetail { FieldName = "Phone" };
     Fax = new ContactDetail { FieldName = "Fax" };
     Website = new ContactDetail { FieldName = "Website" };
     Facebook = new ContactDetail { FieldName = "Facebook", FieldUrl = "www.facebook.com" };
     Twitter = new ContactDetail { FieldName = "Twitter", FieldUrl = "www.twitter.com" };
     Google = new ContactDetail { FieldName = "Google", FieldUrl = "www.google.com" };
     LinkedIn = new ContactDetail { FieldName = "LinkedIn", FieldUrl = "www.linkedin.com" };
     Skype = new ContactDetail { FieldName = "Skype", FieldUrl = "www.skype.com" };
 }
        public bool AddCompanyProfile(CompanyProfile cp)
        {
            try
            {
                cp.State = ObjectState.Added;

                cpRep.AddOperation(cp);
                return true;
            }
            catch (Exception ex)
            {
                var rr = ex.Message;
                return false;
            }
        }
Beispiel #4
0
        public ActionResult UpdateProfile(CompanyProfileCustom companyProfileCustom)
        {
            string proPicErrorMsg = "", ContactAddError = "", msg = "";
            try
            {
                CompanyProfile cp = new CompanyProfile();
                cp = companyProfileCustom.companyProfile;
                HttpPostedFileBase profilePic = Request.Files["profile_pic"];
                var user = uService.GetSingleUserByEmail(HttpContext.User.Identity.Name);
                if (profilePic.ContentLength > 0)
                {
                    string prevImage = Request.MapPath("~/" + cp.ImageLocation);

                    string profilePicName = "Company_" + "_" + cp.Id.ToString() + "_" + Path.GetRandomFileName() + ".png";
                    string profilePicLocation = Server.MapPath("~/Uploads/CompanyProfiles/");
                    if (fileUpload(profilePic, profilePicName, profilePicLocation))
                    {
                        cp.ImageLocation = "Uploads/CompanyProfiles/" + profilePicName;
                        if (System.IO.File.Exists(prevImage))
                        {
                            System.IO.File.Delete(prevImage);
                        }
                    }
                    else
                    {
                        proPicErrorMsg = "Photo Upload Unsuccessfull";
                    }

                }

                if (iCP.UpdateCompanyProfile(cp))
                {
                    try
                    {
                        if (!(iCD.UpdateContactDetail(companyProfileCustom.Phone) && iCD.UpdateContactDetail(companyProfileCustom.Fax) && iCD.UpdateContactDetail(companyProfileCustom.Website) && iCD.UpdateContactDetail(companyProfileCustom.Facebook) && iCD.UpdateContactDetail(companyProfileCustom.Twitter) && iCD.UpdateContactDetail(companyProfileCustom.Google) && iCD.UpdateContactDetail(companyProfileCustom.LinkedIn) && iCD.UpdateContactDetail(companyProfileCustom.Skype)))
                            ContactAddError = "One or more Contact Field Updating Unsuccessfull";
                    }
                    catch (Exception ex)
                    {
                        ContactAddError = "One or more Contact Field Updating Unsuccessfull";
                    }

                }
                else
                {
                    msg = "Profile Updating cannot done successfully!!!!";
                }
            }
            catch (Exception ex)
            {
                msg = "Profile Updating cannot done successfully!!!!";
            }
            TempData.Add("errMsg", msg + ContactAddError + proPicErrorMsg);
            return RedirectToAction("UpdateProfile");
        }
Beispiel #5
0
        public ActionResult AddProfile(CompanyProfileCustom companyProfileCustom)
        {
            string proPicErrorMsg = "", ContactAddError = "", msg = "";
            try
            {
                var user = uService.GetSingleUserByEmail(HttpContext.User.Identity.Name);
                HttpPostedFileBase profilePic = Request.Files["profile_pic"];
                //HttpPostedFileBase doc = Request.Files["documentLocation[]"];
                int companyTableId = iCompany.GetMaxId() + 1;
                CompanyProfile cp = new CompanyProfile();
                cp = companyProfileCustom.companyProfile;
                cp.UserId = user.Id;

                var AccSet = sService.GetAllByUserId(user.Id);

                var myCompany = iCompany.GetSingleCompany(AccSet.Companies.Id);
                cp.Companies = new Company { Id = myCompany.Id };
                if (profilePic.ContentLength > 1)
                {
                    string profilePicName = "Company_" + "_" + companyTableId.ToString() + "_" + Path.GetRandomFileName() + ".png";
                    string profilePicLocation = Server.MapPath("~/Uploads/CompanyProfiles/");
                    if (fileUpload(profilePic, profilePicName, profilePicLocation))
                    {
                        cp.ImageLocation = "Uploads/CompanyProfiles/" + profilePicName;
                    }
                    else
                    {
                        proPicErrorMsg = "Problem in uploading Image";
                    }
                }

                if (iCP.AddCompanyProfile(cp))
                {
                    try
                    {
                        ContactDetail phone = companyProfileCustom.Phone;
                        phone.CompanyProfileId = cp.Id;

                        ContactDetail fax = companyProfileCustom.Fax;
                        fax.CompanyProfileId = cp.Id;

                        ContactDetail facebook = companyProfileCustom.Facebook;
                        facebook.CompanyProfileId = cp.Id;

                        ContactDetail google = companyProfileCustom.Google;
                        google.CompanyProfileId = cp.Id;

                        ContactDetail linkedin = companyProfileCustom.LinkedIn;
                        linkedin.CompanyProfileId = cp.Id;

                        ContactDetail skype = companyProfileCustom.Skype;
                        skype.CompanyProfileId = cp.Id;

                        ContactDetail twitter = companyProfileCustom.Twitter;
                        twitter.CompanyProfileId = cp.Id;

                        ContactDetail website = companyProfileCustom.Website;
                        website.CompanyProfileId = cp.Id;

                        if (!(iCD.AddContactDetail(phone) && iCD.AddContactDetail(fax) && iCD.AddContactDetail(website) && iCD.AddContactDetail(facebook) && iCD.AddContactDetail(twitter) && iCD.AddContactDetail(google) && iCD.AddContactDetail(linkedin) && iCD.AddContactDetail(skype)))
                            ContactAddError = "One or more contact field adding operation failed";
                    }
                    catch (Exception e)
                    {
                        var tt = e;
                        ContactAddError = "One or more contact field adding operation failed...";
                    }

                }
                else
                {
                    msg = "Company Profile adding failed...";
                }

            }
            catch (Exception ex)
            {
                msg = "Something Wrong!!!Please Try again...";

            }
            TempData.Add("errMsg", msg + proPicErrorMsg + ContactAddError);
            return RedirectToAction("updateProfile");
        }
 public bool UpdateCompanyProfile(CompanyProfile cp)
 {
     try
     {
         cp.State = ObjectState.Modified;
         cpRep.UpdateOperation(cp);
         return true;
     }
     catch (Exception ex)
     {
         var rr = ex.Message;
         return false;
     }
 }