Esempio n. 1
0
        public void Upload(string path, string extension, int id)
        {
            var val = Request.Form["upload"];

            var employeeProfile = _profileDataAccess.GetProfileById(id);

            if (employeeProfile == null)
            {
                return;
            }

            var    imageName    = "";
            var    locPath      = _blobServices.BlobUrl;
            var    employeeName = String.Join("", employeeProfile.Employee.Name.Split(' '));
            string type         = "";

            switch (val)
            {
            case "SubmitID":
                type      = "idcards";
                imageName = employeeProfile.Id.ToString() + '.' + employeeName
                            + "_ID" + extension;
                employeeProfile.IdCard = locPath + type + "/" + imageName;
                break;

            case "SubmitCertificate":
                type      = "birthcertificates";
                imageName = employeeProfile.Id.ToString() + '.' + employeeName
                            + "_BirthCertificate" + extension;
                employeeProfile.BirthCertificate = locPath + type + "/" + imageName;
                break;

            case "SubmitPassport":
                type      = "passports";
                imageName = employeeProfile.Id.ToString() + '.' + employeeName
                            + "_Passport" + extension;
                employeeProfile.Passport = locPath + type + "/" + imageName;
                break;

            case "SubmitMilitary":
                type      = "militarycertificates";
                imageName = employeeProfile.Id.ToString() + '.' + employeeName
                            + "_MilitaryCertificate" + extension;
                employeeProfile.MilitaryCertificate = locPath + type + "/" + imageName;
                break;

            case "SubmitGraduation":
                type      = "graduationcertificates";
                imageName = employeeProfile.Id.ToString() + '.' + employeeName
                            + "_GraduationCertificate" + extension;
                employeeProfile.GraduationCertificate = locPath + type + "/" + imageName;
                break;

            case "SubmitProfilePic":
                type      = "profilepics";
                imageName = employeeProfile.Id.ToString() + '.' + employeeName
                            + "_ProfilePic" + extension;
                employeeProfile.ProfilePic = locPath + type + "/" + imageName;
                break;

            case "SubmitExtraDoc":
                type      = "extradocs";
                imageName = employeeProfile.Id.ToString() + '.' + employeeName
                            + "_extraDoc" + extension;
                employeeProfile.ExtraDocument = locPath + type + "/" + imageName;
                break;
            }

            _profileDataAccess.SaveChangesToDb();
            _blobServices.BlobImageUpload(imageName, path, type);
        }