Advertisement
Guest User

Untitled

a guest
Jan 16th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
ASP 5.41 KB | None | 0 0
  1. #region Create Request
  2.                             requestID = Convert.ToInt32(result.Updates[0].Value);
  3.                             var db = DataAccessLayer.DataContext.GetSessionDataContext();
  4.                             BusinessLayer.Request NewRequest = db.Requests.Single(r => r.ID == requestID);
  5.                             //NewRequest.InitiatorName = request.InitiatorName;
  6.  
  7.                             NewRequest.OrganizationID = RequestStructure.DepartmentID;
  8.                             BusinessLayer.BusinessUnit Bu = db.BusinessUnits.Single(r => r.ID == NewRequest.OrganizationID);
  9.                             NewRequest.PCCID = Bu.PCCID;
  10.                             NewRequest.OrganizationName = Bu.Name;
  11.                             NewRequest.SamplingCenterID = RequestStructure.SamplingCenterID;
  12.                             NewRequest.Person.FirstName = RequestStructure.EmployeeInfo.EmployeeNameEn == null ? RequestStructure.EmployeeInfo.EmployeeNameAr.FirstName : RequestStructure.EmployeeInfo.EmployeeNameEn.FirstName;
  13.                             NewRequest.Person.SecondName = RequestStructure.EmployeeInfo.EmployeeNameEn == null ? RequestStructure.EmployeeInfo.EmployeeNameAr.SecondName : RequestStructure.EmployeeInfo.EmployeeNameEn.SecondName;
  14.                             NewRequest.Person.ThirdName = RequestStructure.EmployeeInfo.EmployeeNameEn == null ? RequestStructure.EmployeeInfo.EmployeeNameAr.ThirdName : RequestStructure.EmployeeInfo.EmployeeNameEn.ThirdName;
  15.                             NewRequest.Person.FourthName = RequestStructure.EmployeeInfo.EmployeeNameEn == null ? RequestStructure.EmployeeInfo.EmployeeNameAr.LastName : RequestStructure.EmployeeInfo.EmployeeNameEn.LastName;
  16.                             NewRequest.Person.MobileNumber = RequestStructure.MobileNumber;
  17.                             NewRequest.Person.GenderID = GenderID;
  18.                             NewRequest.Person.NationalityID = NationalityID;
  19.                             NewRequest.Person.OccupationID = OccupationID;
  20.                             NewRequest.Person.ReligionID = ReligionID;
  21.                             NewRequest.Person.DOB = RequestStructure.EmployeeInfo.BirthDate;
  22.                             if (RequestStructure.EmployeePhoto != null && RequestStructure.EmployeePhoto.Length > 0)
  23.                             {
  24.                                 string path = db.Constants.Single(i => i.Code == "UploadedFilesPath").Value + "\\Requests\\" + NewRequest.ID + "\\RequestData\\";
  25.                               //  BusinessLayer.Helpers.WriteFiles.ByteArrayToFile(path, "PersonImage.jpg", RequestStructure.EmployeePhoto);
  26.                                 NewRequest.Person.ImageURL = "PersonImage.jpg";
  27.                             }
  28.                             NewRequest.DOARequest.EmployeeJobName = RequestStructure.JobTitle;
  29.                             NewRequest.DOARequest.EmployerID = 50015;
  30.                             NewRequest.DOARequest.EmployerIDOther = RequestStructure.OtherEmployer;
  31.                             //NewRequest.InitiatorID = 483;
  32.                             NewRequest.DOARequest.LetterNumber = RequestStructure.LetterNumber;
  33.                             // NewRequest.DOARequest.ApprovalRemarks = request.Notes;
  34.  
  35.                             if (RequestStructure.Attachment != null)
  36.                             {
  37.                                 string path = db.Constants.Single(i => i.Code == "UploadedFilesPath").Value + "\\Requests\\" + NewRequest.ID + "\\RequestData\\";
  38.                                 int count = 0;
  39.                                // BusinessLayer.Helpers.WriteFiles.ByteArrayToFile(path, "YasserAttachment" + count, RequestStructure.Attachment);
  40.                             }
  41.                             NewRequest.InitiatorID = Convert.ToInt32(Constant.GetConstantValue("YasserUserID"));
  42.                             NewRequest.InitiatorName = "Yasser Initiator";
  43.  
  44.                             NewRequest.DOARequest.SkipApproval = false;
  45.  
  46.                             db.SubmitChanges(true);
  47.                             try
  48.                             {
  49.                                 ActionResult CreateRequestresult = NewRequest.CreateRequest(requestID);
  50.                             }
  51.                             catch (UserFriendlyException ex)
  52.                             {
  53.                                 if (ex.Code == "DOEAgeMessage")
  54.                                 {
  55.                                     //string label = db.Labels.FirstOrDefault(i => i.Code == ex.Code).Value_En.Replace("{Min}", Constant.GetConstantValue("DOEMinimumAge")).Replace("{Max}", Constant.GetConstantValue("DOEMaximumAge"));
  56.                                     //status = label;
  57.                                     //ErrorCode = "001-000003";
  58.                                     throw new Exception("AGE_NOT_CORRECT");
  59.                                 }
  60.                                 else
  61.                                 {
  62.                                     string label = db.Labels.FirstOrDefault(i => i.Code == ex.Code).Value_En;
  63.                                     status = label + " " + ex.Code;
  64.                                 }
  65.                             }
  66.                             catch (Exception e)
  67.                             {
  68.                                 status = e.Message;
  69.                             }
  70.                             db.SubmitChanges(true);
  71.  
  72.                             #endregion
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement