public ActionResult ManuscriptLogin(ManuscriptLoginVM manuscriptLoginVm, HttpPostedFileBase manuscriptFilePath)
        {
            manuscriptLoginVm.MSID = manuscriptLoginVm.MSID.Trim();
            IDictionary <string, string> dataErrors = new Dictionary <string, string>();

            if (!String.IsNullOrEmpty(manuscriptLoginVm.Associate))
            {
                var empInfo = _manuscriptDBRepositoryReadSide.GetAssociateName(manuscriptLoginVm.Associate);
                if (empInfo.Count() > 0)
                {
                    manuscriptLoginVm.userID = empInfo.FirstOrDefault().UserID;
                }
            }
            if (manuscriptLoginVm.CrestId == 0)
            {
                if (manuscriptLoginVm.IsRevision)
                {
                    //SaveTempFileOnIISServer(manuscriptLoginVm, manuscriptFilePath);
                    AddManuscriptLoginInfo(manuscriptLoginVm, dataErrors);
                }
                else
                {
                    if (!ManuscriptLoginDbRepositoryReadSide.IsMSIDAvailable(manuscriptLoginVm.MSID, manuscriptLoginVm.CrestId))
                    {
                        TempData["MSIDError"] = "<script>alert('Manuscript Number is already present.');</script>";
                    }
                    else
                    {
                        //SaveTempFileOnIISServer(manuscriptLoginVm, manuscriptFilePath);
                        AddManuscriptLoginInfo(manuscriptLoginVm, dataErrors);
                    }
                }
            }
            else
            {
                if (manuscriptLoginVm.IsRevision)
                {
                    //SaveTempFileOnIISServer(manuscriptLoginVm, manuscriptFilePath);
                    AddManuscriptLoginInfo(manuscriptLoginVm, dataErrors);
                }
                else
                {
                    if (ManuscriptLoginDbRepositoryReadSide.IsMSIDAvailable(manuscriptLoginVm.MSID, manuscriptLoginVm.CrestId))
                    {
                        TempData["MSIDError"] = "<script>alert('Manuscript Number is already present.');</script>";
                    }
                    else
                    {
                        var manuscriptLogin = new ManuscriptLogin();
                        manuscriptLogin = ManuscriptLoginDbRepositoryReadSide.GetManuscriptByCrestID(manuscriptLoginVm.CrestId);
                        //code to updated record
                        _manuscriptLoginService.SaveManuscriptLoginVM(dataErrors, manuscriptLoginVm, manuscriptLogin);
                        TempData["msg"] = "<script>alert('Record updated succesfully');</script>";
                    }
                }
            }
            return(RedirectToAction("ManuscriptLogin", new { id = 0 }));
        }
        private void AddManuscriptLoginInfo(ManuscriptLoginVM manuscriptLoginVm, IDictionary <string, string> dataErrors)
        {
            //code to add record
            var manuscriptLogin = new ManuscriptLogin();

            //if new record or revision then add entry into db
            manuscriptLoginVm.CrestId = 0;
            _manuscriptLoginService.SaveManuscriptLoginVM(dataErrors, manuscriptLoginVm, manuscriptLogin);
            TempData["msg"] = "<script>alert('Record added succesfully');</script>";
        }
 private void SaveTempFileOnIISServer(ManuscriptLoginVM manuscriptLoginVm, HttpPostedFileBase manuscriptFilePath)
 {
     if (!String.IsNullOrEmpty(manuscriptLoginVm.ManuscriptFilePath))
     {
         var path = Path.Combine(Server.MapPath("~/App_Data/"), manuscriptFilePath.FileName);
         manuscriptFilePath.SaveAs(path);
         manuscriptLoginVm.ManuscriptFilePath = path;
     }
     else
     {
         manuscriptLoginVm.ManuscriptFilePath = "";
     }
 }
        public bool SaveManuscriptLoginVM(IDictionary <string, string> dataErrors, ManuscriptLoginVM manuscriptLoginVM, Entities.ManuscriptLogin manuscriptLogin)
        {
            ValidateManuscriptLogin(dataErrors, manuscriptLoginVM);
            if (dataErrors.Count == 0)
            {
                manuscriptLoginDTO = new ManuscriptLoginDTO();
                //manuscriptLogin = new Entities.ManuscriptLogin();

                //ManuscriptLogin entity data fill up
                if (manuscriptLoginVM.CrestId == null || manuscriptLoginVM.CrestId == 0)
                {
                    manuscriptLogin.CrestId = Convert.ToInt32(manuscriptLoginVM.CrestId);
                    //manuscriptLogin.ManuscriptFilePath = manuscriptLoginVM.ManuscriptFilePath;
                }

                manuscriptLogin.ArticleTitle          = manuscriptLoginVM.ArticleTitle;
                manuscriptLogin.ArticleTypeId         = manuscriptLoginVM.ArticleTypeID;
                manuscriptLogin.InitialSubmissionDate = manuscriptLoginVM.InitialSubmissionDate;
                manuscriptLogin.SpecialInstruction    = manuscriptLoginVM.SpecialInstruction;
                manuscriptLogin.SectionId             = manuscriptLoginVM.SectionID;
                manuscriptLogin.ReceivedDate          = manuscriptLoginVM.ReceivedDate;
                manuscriptLogin.TaskID              = manuscriptLoginVM.TaskID;
                manuscriptLogin.JournalId           = (manuscriptLoginVM.JournalID == 0) ? manuscriptLogin.JournalId : manuscriptLoginVM.JournalID;
                manuscriptLogin.ServiceTypeStatusId = manuscriptLoginVM.ServiceTypeID;
                manuscriptLogin.MSID = manuscriptLoginVM.MSID;
                //assign manuscriptlogin enitity object to DTO
                manuscriptLoginDTO.manuscriptLogin = manuscriptLogin;
                manuscriptLoginDTO.AssociateName   = manuscriptLoginVM.Associate;
                manuscriptLoginDTO.IsRevision      = manuscriptLoginVM.IsRevision;
                if (_manuscriptLoginBL.SaveManuscriptLogin(manuscriptLoginDTO, dataErrors))
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                return(false);
            }
        }
        public ActionResult ManuscriptLogin(int?id)
        {
            var manuscriptLoginVm = new ManuscriptLoginVM();
            var userId            = @System.Web.HttpContext.Current.User.Identity.Name.Replace("SPRINGER-SBM\\", "");

            manuscriptLoginVm._journal = _manuscriptDBRepositoryReadSide.GetJournalList();
            var crestId = Convert.ToInt32(id);

            if (id != null && id != 0)
            {
                ManuscriptLoginVmDetails(manuscriptLoginVm, crestId);
            }
            manuscriptLoginVm._articleType          = _manuscriptDBRepositoryReadSide.GetArticleList(Convert.ToInt32(manuscriptLoginVm.JournalID));
            manuscriptLoginVm._section              = _manuscriptDBRepositoryReadSide.GetSectionList(Convert.ToInt32(manuscriptLoginVm.JournalID));
            manuscriptLoginVm._TaskList             = _manuscriptDBRepositoryReadSide.GetTaskType();
            manuscriptLoginVm._serviceType          = _manuscriptDBRepositoryReadSide.GetServiceType();
            manuscriptLoginVm.EmployeeName          = _manuscriptDBRepositoryReadSide.EmployeeName(userId);
            manuscriptLoginVm.manuscriptLoginedJobs = ManuscriptLoginDbRepositoryReadSide.GetManuscriptLoginJobs();
            return(View(manuscriptLoginVm));
        }
        private void ManuscriptLoginVmDetails(ManuscriptLoginVM manuscriptLoginVm, int crestId)
        {
            ManuscriptLogin manuscriptLogin;
            var             manuscriptLoginDetails = new ManuscriptLoginDetails();

            manuscriptLogin                      = ManuscriptLoginDbRepositoryReadSide.GetManuscriptByCrestID(crestId);
            manuscriptLoginVm.CrestId            = manuscriptLogin.CrestId;
            manuscriptLoginVm.SpecialInstruction = manuscriptLogin.SpecialInstruction;
            //change as per id
            if (manuscriptLogin.ServiceTypeStatusId == 9)
            {
                manuscriptLoginDetails = ManuscriptLoginDbRepositoryReadSide.GetManuscriptLoginDetails(manuscriptLogin.CrestId, ManuscriptLoginDbRepositoryReadSide.MSServiceTypeID());
            }
            else
            {
                manuscriptLoginDetails = ManuscriptLoginDbRepositoryReadSide.GetManuscriptLoginDetails(manuscriptLogin.CrestId, manuscriptLogin.ServiceTypeStatusId);
            }
            if (manuscriptLoginDetails != null)
            {
                if (manuscriptLoginDetails.UserRoleId != null && manuscriptLoginDetails.UserRoleId != 0)
                {
                    var usernameID = ManuscriptLoginDbRepositoryReadSide.GetUserID(Convert.ToInt32(manuscriptLoginDetails.UserRoleId)).UserID;
                    manuscriptLoginVm.Associate = _manuscriptDBRepositoryReadSide.EmployeeName(usernameID);
                }
            }
            manuscriptLoginVm.InitialSubmissionDate = manuscriptLogin.InitialSubmissionDate;
            manuscriptLoginVm.ManuscriptFilePath    = manuscriptLogin.ManuscriptFilePath;
            manuscriptLoginVm.ServiceTypeID         = manuscriptLogin.ServiceTypeStatusId;
            manuscriptLoginVm.ArticleTypeID         = manuscriptLogin.ArticleTypeId;
            manuscriptLoginVm.JournalID             = manuscriptLogin.JournalId;
            manuscriptLoginVm.MSID         = manuscriptLogin.MSID;
            manuscriptLoginVm.SectionID    = manuscriptLogin.SectionId;
            manuscriptLoginVm.ArticleTitle = manuscriptLogin.ArticleTitle;
            manuscriptLoginVm.ReceivedDate = manuscriptLogin.ReceivedDate;
            manuscriptLoginVm.TaskID       = manuscriptLogin.TaskID;
        }
 private void ValidateManuscriptLogin(IDictionary <string, string> dataErrors, ManuscriptLoginVM manuscriptLoginVM)
 {
     if (manuscriptLoginVM.JournalID == null)
     {
         dataErrors.Add("JournalID", "JournalTitle is required.");
     }
     if (manuscriptLoginVM.ArticleTypeID == null)
     {
         dataErrors.Add("ArticleTypeID", "Article Type is required.");
     }
     if (manuscriptLoginVM.ArticleTitle == null)
     {
         dataErrors.Add("ArticleTitle", "Article Title is required.");
     }
     if (manuscriptLoginVM.InitialSubmissionDate == null)
     {
         dataErrors.Add("InitialSubmissionDate", "Initial Submission Date is required.");
     }
     if (manuscriptLoginVM.MSID == null)
     {
         dataErrors.Add("MSID", "Manuscript Number is required.");
     }
     if (manuscriptLoginVM.ServiceTypeID == null)
     {
         dataErrors.Add("ServiceTypeID", "Service Type is required.");
     }
 }