Esempio n. 1
0
        public ActionResult PrincipalNomineeDataEntry(List <ScmUploadedData> scmdata, HttpPostedFileBase SCMHardcopy, string Remarks)
        {
            List <ScmUploadedData> scmcheckeddata = scmdata.ToList();
            int collegeId = 0;
            int SCMId     = 0;

            if (scmcheckeddata.Count() != 0 && User.Identity.Name != null && SCMHardcopy != null)
            {
                collegeId = scmcheckeddata[0].CollegeId;
                var emailId = db.jntuh_registration.Where(e => e.Email == User.Identity.Name).Select(e => e.Email).FirstOrDefault();
                int userId  = db.jntuh_ffc_auditor.Where(e => e.isActive == true && e.auditorEmail1 == emailId && e.auditorDepartmentID == 60).Select(e => e.id).FirstOrDefault();
                if (userId != 0)
                {
                    var          fileName            = string.Empty;
                    var          filepath            = string.Empty;
                    var          collegescmrequests  = new jntuh_scmproceedingsrequests();
                    const string scmnotificationpath = "~/Content/Upload/SCMPROCEEDINGSREQUEST/UploadSCMHardCopy";
                    if (SCMHardcopy != null)
                    {
                        if (!Directory.Exists(Server.MapPath(scmnotificationpath)))
                        {
                            Directory.CreateDirectory(Server.MapPath(scmnotificationpath));
                        }

                        var ext = Path.GetExtension(SCMHardcopy.FileName);
                        if (ext != null)
                        {
                            var scmfileName = scmcheckeddata[0].CollegeId + "_" + "UploadSCMHardCopyForPrincipal" + "_" + DateTime.Now.ToString("yyyMMddHHmmss");
                            SCMHardcopy.SaveAs(string.Format("{0}/{1}{2}", Server.MapPath(scmnotificationpath), scmfileName, ext));
                            fileName = scmfileName + ext;
                        }
                    }

                    foreach (var item in scmcheckeddata)
                    {
                        if (item != null)
                        {
                            jntuh_auditors_dataentry dataentry = new jntuh_auditors_dataentry();
                            dataentry.CollegeId        = item.CollegeId;
                            dataentry.SpecializationId = 0;
                            dataentry.DepartmentId     = 0;
                            dataentry.DegreeId         = 0;
                            dataentry.DesignationId    = 0;
                            dataentry.RegistrationNo   = item.RegistrationNumber;
                            dataentry.AuditorId        = userId;
                            dataentry.IsSelected       = item.Checked;
                            dataentry.IsActive         = true;
                            dataentry.NomineeRemarks   = Remarks;
                            dataentry.CreatedBy        = userId;
                            dataentry.CreatedOn        = DateTime.Now;
                            dataentry.SCMhardcopy      = fileName;
                            dataentry.ScmProceedingId  = item.SCMId;
                            SCMId = item.SCMId;
                            db.jntuh_auditors_dataentry.Add(dataentry);
                        }
                    }
                    TempData["Success"] = "Information Saved Successfully";
                    db.SaveChanges();

                    var AuditorAssignedData = db.jntuh_auditor_assigned.Where(e => e.AuditorId == userId && e.ScmId == SCMId).Select(e => e).FirstOrDefault();
                    if (AuditorAssignedData != null)
                    {
                        AuditorAssignedData.RequestSubmittedDate = DateTime.Now;
                        AuditorAssignedData.UpdatedBy            = userId;
                        AuditorAssignedData.UpdatedOn            = DateTime.Now;
                        db.Entry(AuditorAssignedData).State      = EntityState.Modified;
                        db.SaveChanges();
                    }



                    // return RedirectToAction("PrincipalNomineeDataEntry", "User", new { collegeId = collegeId });
                    return(RedirectToAction("ApprovedFacultyBasedOnNominee", "Admin", new { SCMId = SCMId }));
                }
            }
            return(View());
        }
Esempio n. 2
0
        public ActionResult Index(List <ScmUploadedData> scmdata, HttpPostedFileBase SCMHardcopy, int?DesignationId, string Remarks)
        {
            List <ScmUploadedData> scmcheckeddata = scmdata.ToList();
            int collegeId        = 0;
            int specializationId = 0;
            int SCMId            = 0;

            if (scmcheckeddata.Count() != 0 && User.Identity.Name != null && SCMHardcopy != null)
            {
                List <int> SCMIds = new List <int>();
                collegeId        = scmcheckeddata[0].CollegeId;
                specializationId = scmcheckeddata[0].SpecializationId;

                // var emailId =db.jntuh_registration.Where(e => e.Email == User.Identity.Name).Select(e => e.Email).FirstOrDefault();
                int userId = scmcheckeddata.GroupBy(e => e.AuditorId).Select(e => e.Key).FirstOrDefault();

                var AuditorAssignSCMIds = scmcheckeddata.GroupBy(e => e.SCMId).Select(e => e.Key).ToArray();
                SCMIds.AddRange(scmcheckeddata.GroupBy(e => e.SCMId).Select(e => e.Key).ToArray());

                //db.jntuh_ffc_auditor.Where(e => e.isActive == true && e.auditorEmail1 == emailId).Select(e => e.id).FirstOrDefault();
                //  var AuditorsIds =db.jntuh_auditor_assigned.Where(e => e.ScmId == scmdata[0].SCMId).Select(e => e.AuditorId).Distinct().ToArray();
                if (userId != 0)
                {
                    string scmIds = "";
                    foreach (var ids in SCMIds)
                    {
                        if (!string.IsNullOrEmpty(scmIds))
                        {
                            scmIds += "," + ids.ToString();
                        }
                        else
                        {
                            scmIds = ids.ToString();
                        }
                    }



                    var          fileName            = string.Empty;
                    var          filepath            = string.Empty;
                    var          collegescmrequests  = new jntuh_scmproceedingsrequests();
                    const string scmnotificationpath = "~/Content/Upload/SCMPROCEEDINGSREQUEST/UploadSCMHardCopy";
                    if (SCMHardcopy != null)
                    {
                        if (!Directory.Exists(Server.MapPath(scmnotificationpath)))
                        {
                            Directory.CreateDirectory(Server.MapPath(scmnotificationpath));
                        }

                        var ext = Path.GetExtension(SCMHardcopy.FileName);
                        if (ext != null)
                        {
                            var scmfileName = scmcheckeddata[0].CollegeId + "_" + "UploadSCMHardCopy" + "_" + DateTime.Now.ToString("yyyMMddHHmmss");
                            SCMHardcopy.SaveAs(string.Format("{0}/{1}{2}", Server.MapPath(scmnotificationpath), scmfileName, ext));
                            fileName = scmfileName + ext;
                        }
                    }

                    foreach (var item in scmcheckeddata)
                    {
                        if (item != null)
                        {
                            jntuh_auditors_dataentry dataentry = new jntuh_auditors_dataentry();
                            dataentry.CollegeId        = item.CollegeId;
                            dataentry.SpecializationId = item.SpecializationId;
                            dataentry.DepartmentId     = item.DepartmentId;
                            dataentry.DegreeId         = item.DegreeId;
                            dataentry.DesignationId    = (int)(DesignationId ?? 0);
                            dataentry.RegistrationNo   = item.RegistrationNumber;
                            dataentry.AuditorId        = userId;
                            dataentry.IsSelected       = item.Checked;
                            dataentry.IsActive         = true;
                            dataentry.CreatedBy        = userId;
                            dataentry.NomineeRemarks   = Remarks;
                            dataentry.CreatedOn        = DateTime.Now;
                            dataentry.SCMhardcopy      = fileName;
                            dataentry.ScmProceedingId  = item.SCMId;
                            dataentry.DesignationId    = item.DesignationId;
                            SCMId = item.SCMId;

                            db.jntuh_auditors_dataentry.Add(dataentry);
                        }
                    }
                    db.SaveChanges();
                    var jntuh_auditor_assign = db.jntuh_auditor_assigned.AsNoTracking().ToList();
                    if (AuditorAssignSCMIds.Count() != 0)
                    {
                        foreach (var adata in AuditorAssignSCMIds)
                        {
                            var AuditoeAssigneddata = db.jntuh_auditor_assigned.Where(e => e.ScmId == adata && e.CollegeId == collegeId).ToList();
                            if (AuditoeAssigneddata.Count() != 0)
                            {
                                AuditoeAssigneddata.ForEach(e =>
                                {
                                    e.RequestSubmittedDate = DateTime.Now;
                                    e.UpdatedBy            = userId;
                                    e.UpdatedOn            = DateTime.Now;
                                });

                                // var AuditorAssigndata = db.jntuh_auditor_assigned.Find(Aid);
                                // AuditorAssigndata.RequestSubmittedDate = DateTime.Now;
                                // AuditorAssigndata.UpdatedBy = userId;
                                // AuditorAssigndata.UpdatedOn = DateTime.Now;
                                //db.Entry(AuditorAssigndata).State=EntityState.Modified;
                                db.SaveChanges();
                            }
                        }
                    }



                    TempData["Success"] = "Information Saved Successfully";

                    //  return RedirectToAction("Index", "User",new {collegeId = collegeId, specializationId = specializationId});
                    return(RedirectToAction("ApprovedFacultyBasedOnNominee", "Admin", new { SCMId = scmIds }));
                }
            }
            return(View());
        }