Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #region Create Request
- requestID = Convert.ToInt32(result.Updates[0].Value);
- var db = DataAccessLayer.DataContext.GetSessionDataContext();
- BusinessLayer.Request NewRequest = db.Requests.Single(r => r.ID == requestID);
- //NewRequest.InitiatorName = request.InitiatorName;
- NewRequest.OrganizationID = RequestStructure.DepartmentID;
- BusinessLayer.BusinessUnit Bu = db.BusinessUnits.Single(r => r.ID == NewRequest.OrganizationID);
- NewRequest.PCCID = Bu.PCCID;
- NewRequest.OrganizationName = Bu.Name;
- NewRequest.SamplingCenterID = RequestStructure.SamplingCenterID;
- NewRequest.Person.FirstName = RequestStructure.EmployeeInfo.EmployeeNameEn == null ? RequestStructure.EmployeeInfo.EmployeeNameAr.FirstName : RequestStructure.EmployeeInfo.EmployeeNameEn.FirstName;
- NewRequest.Person.SecondName = RequestStructure.EmployeeInfo.EmployeeNameEn == null ? RequestStructure.EmployeeInfo.EmployeeNameAr.SecondName : RequestStructure.EmployeeInfo.EmployeeNameEn.SecondName;
- NewRequest.Person.ThirdName = RequestStructure.EmployeeInfo.EmployeeNameEn == null ? RequestStructure.EmployeeInfo.EmployeeNameAr.ThirdName : RequestStructure.EmployeeInfo.EmployeeNameEn.ThirdName;
- NewRequest.Person.FourthName = RequestStructure.EmployeeInfo.EmployeeNameEn == null ? RequestStructure.EmployeeInfo.EmployeeNameAr.LastName : RequestStructure.EmployeeInfo.EmployeeNameEn.LastName;
- NewRequest.Person.MobileNumber = RequestStructure.MobileNumber;
- NewRequest.Person.GenderID = GenderID;
- NewRequest.Person.NationalityID = NationalityID;
- NewRequest.Person.OccupationID = OccupationID;
- NewRequest.Person.ReligionID = ReligionID;
- NewRequest.Person.DOB = RequestStructure.EmployeeInfo.BirthDate;
- if (RequestStructure.EmployeePhoto != null && RequestStructure.EmployeePhoto.Length > 0)
- {
- string path = db.Constants.Single(i => i.Code == "UploadedFilesPath").Value + "\\Requests\\" + NewRequest.ID + "\\RequestData\\";
- // BusinessLayer.Helpers.WriteFiles.ByteArrayToFile(path, "PersonImage.jpg", RequestStructure.EmployeePhoto);
- NewRequest.Person.ImageURL = "PersonImage.jpg";
- }
- NewRequest.DOARequest.EmployeeJobName = RequestStructure.JobTitle;
- NewRequest.DOARequest.EmployerID = 50015;
- NewRequest.DOARequest.EmployerIDOther = RequestStructure.OtherEmployer;
- //NewRequest.InitiatorID = 483;
- NewRequest.DOARequest.LetterNumber = RequestStructure.LetterNumber;
- // NewRequest.DOARequest.ApprovalRemarks = request.Notes;
- if (RequestStructure.Attachment != null)
- {
- string path = db.Constants.Single(i => i.Code == "UploadedFilesPath").Value + "\\Requests\\" + NewRequest.ID + "\\RequestData\\";
- int count = 0;
- // BusinessLayer.Helpers.WriteFiles.ByteArrayToFile(path, "YasserAttachment" + count, RequestStructure.Attachment);
- }
- NewRequest.InitiatorID = Convert.ToInt32(Constant.GetConstantValue("YasserUserID"));
- NewRequest.InitiatorName = "Yasser Initiator";
- NewRequest.DOARequest.SkipApproval = false;
- db.SubmitChanges(true);
- try
- {
- ActionResult CreateRequestresult = NewRequest.CreateRequest(requestID);
- }
- catch (UserFriendlyException ex)
- {
- if (ex.Code == "DOEAgeMessage")
- {
- //string label = db.Labels.FirstOrDefault(i => i.Code == ex.Code).Value_En.Replace("{Min}", Constant.GetConstantValue("DOEMinimumAge")).Replace("{Max}", Constant.GetConstantValue("DOEMaximumAge"));
- //status = label;
- //ErrorCode = "001-000003";
- throw new Exception("AGE_NOT_CORRECT");
- }
- else
- {
- string label = db.Labels.FirstOrDefault(i => i.Code == ex.Code).Value_En;
- status = label + " " + ex.Code;
- }
- }
- catch (Exception e)
- {
- status = e.Message;
- }
- db.SubmitChanges(true);
- #endregion
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement