Exemplo n.º 1
0
 public EmployeeProfileCustom(EmployeeProfile employeeProfile)
 {
     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" };
 }
Exemplo n.º 2
0
        public EmployeeProfileCustom GetEmployeeProfile(long userId)
        {
            try {
                var empProfile = epRep.GetOperation()
                                   .Include(ep => ep.ContactDetails)
                                   .Filter(ep => ep.Users.Id == userId)
                                   .Get().FirstOrDefault();
                var empProfileObj = new EmployeeProfile
                {
                    Id = empProfile.Id,
                    ImageLocation = empProfile.ImageLocation,
                    Bio=empProfile.Bio,
                    IsActive = empProfile.IsActive,
                    JobTitle = empProfile.JobTitle,
                    Location = empProfile.Location
                };
                var empProfileCustom = new EmployeeProfileCustom();
                empProfileCustom.employeeProfile = empProfileObj;

                if (empProfile.ContactDetails.Count < 1)
                {
                    return null;
                }
                foreach (var oo in empProfile.ContactDetails)
                {
                    if (oo.FieldName == "Phone")
                        empProfileCustom.Phone = GetContactObject(oo);
                    else if (oo.FieldName == "Fax")
                        empProfileCustom.Fax = GetContactObject(oo);
                    else if (oo.FieldName == "Website")
                        empProfileCustom.Website = GetContactObject(oo);
                    else if (oo.FieldName == "Facebook")
                        empProfileCustom.Facebook = GetContactObject(oo);
                    else if (oo.FieldName == "Twitter")
                        empProfileCustom.Twitter = GetContactObject(oo);
                    else if (oo.FieldName == "Google")
                        empProfileCustom.Google = GetContactObject(oo);
                    else if (oo.FieldName == "LinkedIn")
                        empProfileCustom.LinkedIn = GetContactObject(oo);
                    else if (oo.FieldName == "Skype")
                        empProfileCustom.Skype = GetContactObject(oo);
                }
                return empProfileCustom;
            }
            catch (Exception ex)
            {
                return null;
            }
        }
Exemplo n.º 3
0
        public bool AddEmployeeProfile(EmployeeProfile ep)
        {
            try
            {
                ep.State = ObjectState.Added;

                epRep.AddOperation(ep);
                return true;
            }
            catch (Exception ex)
            {
                var rr = ex.Message;
                return false;
            }
        }
Exemplo n.º 4
0
        public ActionResult Create(EmployeeProfileCustom employeeProfileCustom)
        {
            string msg="", profilePicErr = "",contactDetailErr="";
            bool success = false;
            try
            {
                var user = uService.GetSingleUserByEmail(HttpContext.User.Identity.Name);
                HttpPostedFileBase profilePic = Request.Files["profile_pic"];
                //HttpPostedFileBase doc = Request.Files["documentLocation[]"];

                string profilePicName = "Employee" + "_" + user.Id.ToString() + "_" + Path.GetRandomFileName() + ".png";
                string profilePicLocation = Server.MapPath("~/Uploads/EmployeeProfiles/");
                EmployeeProfile ep = new EmployeeProfile();
                ep = employeeProfileCustom.employeeProfile;
                ep.Users = new User { Id = user.Id, Email = user.Email };
                if (profilePic.ContentLength > 1)
                {
                    if (ImageUpload(profilePic, profilePicName, profilePicLocation))
                    {
                        ep.ImageLocation = "Uploads/EmployeeProfiles/" + profilePicName;
                    }
                    else
                        profilePicErr = "Picture Upload Unsuccessfull!!!";
                }

                if (iEP.AddEmployeeProfile(ep))
                {
                    success = true;
                    try
                    {
                        ContactDetail phone = employeeProfileCustom.Phone;
                        phone.EmployeeProfileId = ep.Id;

                        ContactDetail fax = employeeProfileCustom.Fax;
                        fax.EmployeeProfileId = ep.Id;

                        ContactDetail facebook = employeeProfileCustom.Facebook;
                        facebook.EmployeeProfileId = ep.Id;

                        ContactDetail google = employeeProfileCustom.Google;
                        google.EmployeeProfileId = ep.Id;

                        ContactDetail linkedin = employeeProfileCustom.LinkedIn;
                        linkedin.EmployeeProfileId = ep.Id;

                        ContactDetail skype = employeeProfileCustom.Skype;
                        skype.EmployeeProfileId = ep.Id;

                        ContactDetail twitter = employeeProfileCustom.Twitter;
                        twitter.EmployeeProfileId = ep.Id;

                        ContactDetail website = employeeProfileCustom.Website;
                        website.EmployeeProfileId = ep.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)))
                            contactDetailErr = "One or more Contact Details could not added successfully..";
                    }
                    catch (Exception e)
                    {
                        var tt = e;
                        contactDetailErr = "One or more Contact Details could not added successfully..";
                    }
                    msg = "Success";

                }
                else
                    msg = "Profile could not Added Successfully....";

            }
            catch (Exception ex)
            {
                msg = "Profile could not Added Successfully....";
            }
            TempData.Add("errMsg",msg+profilePicErr+contactDetailErr);
            if (!success)
                return RedirectToAction("Create");

            return RedirectToAction("MyMhasb", "Users", new { Area = "UserManagement" });
        }
Exemplo n.º 5
0
        public ActionResult Update(EmployeeProfileCustom employeeProfileCustom)
        {
            string msg="", profilePicErr = "",contactDetailErr="";
            bool success = false;
            try
            {
                EmployeeProfile ep = new EmployeeProfile();
                ep = employeeProfileCustom.employeeProfile;
                HttpPostedFileBase profilePic = Request.Files["profile_pic"];
                var user = uService.GetSingleUserByEmail(HttpContext.User.Identity.Name);
                string profilePicName;
                string profilePicLocation;
                string tempPath = Server.MapPath("~/Uploads/Temp");
                if(profilePic.ContentLength>0)
                {
                    if (!Directory.Exists(tempPath))
                    {
                        Directory.CreateDirectory(tempPath);
                    }

                    if (ep.ImageLocation== null)
                    {
                        profilePicName =  "Employee" + "_" + user.Id.ToString() + "_" + Path.GetRandomFileName() + ".png";
                        profilePicLocation = Server.MapPath("~/Uploads/EmployeeProfiles/");
                    }
                    else
                    {
                        profilePicName = ep.ImageLocation.Split('/').Last();
                        profilePicLocation = ep.ImageLocation;
                        profilePicLocation = Path.GetDirectoryName(profilePicLocation);
                        profilePicLocation = Server.MapPath("~/" + profilePicLocation + "/");
                        if (System.IO.File.Exists(profilePicLocation+profilePic))
                        {
                            System.IO.File.Move(profilePicLocation + profilePic, tempPath + profilePic);
                        }
                    }

                    if (ImageUpload(profilePic, profilePicName, profilePicLocation))
                    {
                        ep.ImageLocation = "Uploads/EmployeeProfiles/" + profilePicName;
                        if (System.IO.File.Exists(tempPath+profilePicName))
                        {
                            System.IO.File.Delete(tempPath+profilePicName);
                        }
                    }
                    else
                    {
                        if (System.IO.File.Exists(tempPath + profilePic))
                        {
                            System.IO.File.Move(tempPath + profilePic, profilePicLocation + profilePic);
                        }
                        profilePicErr = "New Image could not uploaded Successfully....";
                    }

                }

                if (iEP.UpdateEmployeeProfile(ep))
                {
                    success = true;
                    try
                    {
                        if (!(iCD.UpdateContactDetail(employeeProfileCustom.Phone) && iCD.UpdateContactDetail(employeeProfileCustom.Fax) && iCD.UpdateContactDetail(employeeProfileCustom.Website) && iCD.UpdateContactDetail(employeeProfileCustom.Facebook) && iCD.UpdateContactDetail(employeeProfileCustom.Twitter) && iCD.UpdateContactDetail(employeeProfileCustom.Google) && iCD.UpdateContactDetail(employeeProfileCustom.LinkedIn) && iCD.UpdateContactDetail(employeeProfileCustom.Skype)))
                            contactDetailErr="One or more Contact Field Updating Unsuccessfull!!!";

                    }
                    catch (Exception ex)
                    {
                        contactDetailErr = "One or more Contact Field Updating Unsuccessfull!!!!";
                    }

                    msg = "Your profile is successfully Updated";

                }
                else
                {
                    //if (System.IO.File.Exists(tempPath + profilePic))
                    //{
                    //    System.IO.File.Move(tempPath + profilePic, profilePicLocation + profilePic);
                    //}
                    msg="Profile Updating cannot done successfully";
                }
            }
            catch (Exception ex)
            {
                msg = "Profile Updating cannot done successfully";
            }

            TempData.Add("errMsg",msg+profilePicErr+contactDetailErr);
            if (!success)
                return RedirectToAction("Update");

            return RedirectToAction("MyMhasb", "Users", new { Area = "UserManagement" });
        }
Exemplo n.º 6
0
 public bool UpdateEmployeeProfile(EmployeeProfile ep)
 {
     try
     {
         ep.State = ObjectState.Modified;
         epRep.UpdateOperation(ep);
         return true;
     }
     catch (Exception ex)
     {
         var rr = ex.Message;
         return false;
     }
 }