private void SaveAuthRepDocumentDetails(int authRepId) { IList<AuthRepDocDetailDTO> listAuthRep = new List<AuthRepDocDetailDTO>(); IList<AuthRepDocumentsDTO> listAuthRepDocument = new List<AuthRepDocumentsDTO>(); foreach (GridViewRow row in grdDocument.Rows) { if (row.RowType == DataControlRowType.DataRow) { if (((TextBox)(row.Cells[3].Controls[1])).Text != string.Empty) { AuthRepDocDetailDTO authRepDocDetails = new AuthRepDocDetailDTO(); authRepDocDetails.AuthRep_Doc_AuthId = authRepId; authRepDocDetails.AuthRep_Doc_DocId = Convert.ToInt32(grdDocument.DataKeys[row.RowIndex].Value); authRepDocDetails.AuthRep_Doc_DocNo = ((TextBox)(row.Cells[3].Controls[1])).Text; DateTimeFormatInfo dateTimeFormatterProvider = DateTimeFormatInfo.CurrentInfo.Clone() as DateTimeFormatInfo; dateTimeFormatterProvider.ShortDatePattern = "dd/MM/yyyy"; if (((TextBox)(row.Cells[4].Controls[1])).Text != string.Empty) { authRepDocDetails.AuthRep_Doc_ExDate = DateTime.Parse(((TextBox)(row.Cells[4].Controls[1])).Text, dateTimeFormatterProvider); } AuthRepDocumentsDTO authRepDocument = new AuthRepDocumentsDTO(); authRepDocument.AuthRepDoc_CreatedBy = base.GetCurrentUserId(); authRepDocument.AuthRepDoc_CreatedDate = DateTime.Now; if (((Label)(row.Cells[6].Controls[1])).Text.Trim() != string.Empty) { string filePath = Path.Combine(Convert.ToString(ViewState[Globals.StateMgmtVariables.FILEPATH]), ((Label)(row.Cells[6].Controls[1])).Text); authRepDocument.AuthRepDoc_File = ImageToBlob.ConvertImageToByteArray(filePath); } else { authRepDocument.AuthRepDoc_File = null; } listAuthRepDocument.Add(authRepDocument); authRepDocDetails.AuthRep_Doc_FileName = ((Label)(row.Cells[6].Controls[1])).Text; authRepDocDetails.AuthRep_Doc_CreatedBy = GetCurrentUserId(); authRepDocDetails.AuthRep_Doc_CreatedDate = DateTime.Now; authRepDocDetails.AuthRep_Doc_LastUpdatedDate = DateTime.Now; listAuthRep.Add(authRepDocDetails); } } } //Save Auth Rep Document Details ESalesUnityContainer.Container.Resolve<IAuthRepService>().SaveAndUpdateAuthRepDocDetails(listAuthRep, listAuthRepDocument); }
/// <summary> /// Get Auth Rep Doc Details By DocId /// </summary> /// <param name="authRepDocId"></param> /// <returns></returns> public AuthRepDocumentsDTO GetAuthRepDocDetailsByDocId(int authRepDocId) { AuthRepDocumentsDTO authRepDocument = new AuthRepDocumentsDTO(); AutoMapper.Mapper.Map(ESalesUnityContainer.Container.Resolve<IGenericRepository<authrepdocument>>() .GetSingle(item => item.AuthRepDoc_Doc_Id == authRepDocId && item.AuthRepDoc_IsDeleted == false), authRepDocument); return authRepDocument; }