/// <summary> /// This method is used for fetching supplier return request from database. - JJ /// </summary> /// <param name="id">id of supplier return detail</param> /// <returns>object of SupplierReturnRequest</returns> public SupplierReturnRequest GetSupReturnRequest(int id) { try { var supplierReturn = _supplierReturnDetailContext.Find(id); var log = _IWorkFlowDetailsRepository.GetAllWorkFlowActionList(supplierReturn.RecordId); if (supplierReturn.IsRejected || supplierReturn.IsDeleted) { var workFlowActionAc = new WorkFlowActionAc(); if (supplierReturn.IsRejected) { var rejector = _userDetailContext.Find(supplierReturn.RejectorId); workFlowActionAc.Stage = "Rejected by " + rejector.RoleName; workFlowActionAc.Action = StringConstants.RejectAction; workFlowActionAc.UserName = rejector.UserName; workFlowActionAc.RoleName = rejector.RoleName; } else { workFlowActionAc.Stage = "Deleted by " + supplierReturn.Initiator.RoleName; workFlowActionAc.Action = "Deleted"; workFlowActionAc.UserName = supplierReturn.Initiator.UserName; workFlowActionAc.RoleName = supplierReturn.Initiator.RoleName; } workFlowActionAc.Comment = supplierReturn.Comment; workFlowActionAc.ActionDate = String.Format("{0:dd-MM-yyyy}", supplierReturn.RejectedDate); log.Add(workFlowActionAc); } var supplierReturnItem = ConvertToApplicationClass(_supplierReturnItemContext.Fetch(x => x.SupplierReturnId == id).ToList()); var supplierReturnRequest = new SupplierReturnRequest { BranchId = supplierReturn.BranchId, BranchName = supplierReturn.BranchDetail.Name, InitiationDate = supplierReturn.CreatedDateTime, IsRejected = supplierReturn.IsRejected, RequestNo = supplierReturn.RequestNo, Initiator = supplierReturn.Initiator.FullName, InitiatorId = supplierReturn.InitiatorId, IsDeleted = supplierReturn.IsDeleted, SupplierId = supplierReturn.SupplierId, SupplierName = supplierReturn.SupplierProfile.NameEn, SupplierCode = supplierReturn.SupplierProfile.Code, SupplierReturnId = supplierReturn.Id, SupplierReturnItemAC = supplierReturnItem, RecordId = supplierReturn.RecordId, WorkFlowLog = log }; return(supplierReturnRequest); } catch (Exception ex) { _errorLog.LogException(ex); throw; } }
/// <summary> /// this method is used to get incident report details by id. /// </summary> /// <param name="incidentId"></param> /// <param name="userDetail"></param> /// <returns></returns> public PosIncidentReportAc GetIncidentReportDetailsById(int incidentId, UserDetail userDetail, bool isAllowToAccessAllBranch) { try { var incidentReportDetail = _posIncidentReportDataRepository.FirstOrDefault(x => x.Id == incidentId); var incidentAc = new PosIncidentReportAc(); incidentAc = ApplicationClassHelper.ConvertType <DomainModel.Models.IncidentReport.PosIncidentReport, PosIncidentReportAc>(incidentReportDetail); incidentAc.PosIncidentReportId = incidentReportDetail.Id; incidentAc.IncidentTypeName = incidentReportDetail.IncidentTypes.ValueEn; incidentAc.LossValue = incidentReportDetail.CommittedLossValue; incidentAc.GainValue = incidentReportDetail.CommittedGainValue; incidentAc.ResolveQuantity = incidentReportDetail.CommitedQuantity; incidentAc.ItemName = incidentReportDetail.ItemProfile.ItemNameEn; incidentAc.BranchName = incidentReportDetail.BranchDetail.Name; incidentAc.IsDisabledInfo = true; incidentAc.CostPrice = incidentReportDetail.ItemProfile.CostPrice; incidentAc.IncidentDate = incidentReportDetail.CreatedDateTime.ToString("dd/MM/yyyy hh:mm"); incidentAc.SellPrice = incidentReportDetail.ItemProfile.SellPrice; var itemQuantityDetails = _itemQuantityContext.FirstOrDefault(x => x.ItemId == incidentReportDetail.ItemId && x.BranchId == incidentReportDetail.BranchId); if (itemQuantityDetails != null) { incidentAc.CurrentSystemQuantity = itemQuantityDetails.ActualQuantity; } var itemOfferDetail = new ItemOfferDetailAC { ItemId = incidentReportDetail.ItemId, Barcode = incidentReportDetail.ItemProfile.Barcode, ItemNameEn = incidentReportDetail.ItemProfile.ItemNameEn, FlavourEn = incidentReportDetail.ItemProfile.FlavourEn, ItemCode = incidentReportDetail.ItemProfile.Code, SellPriceA = incidentReportDetail.ItemProfile.SellPriceA, SellPrice = incidentReportDetail.ItemProfile.SellPrice, SellPriceB = incidentReportDetail.ItemProfile.SellPriceB, SellPriceC = incidentReportDetail.ItemProfile.SellPriceC, SellPriceD = incidentReportDetail.ItemProfile.SellPriceD, UnitType = incidentReportDetail.ItemProfile.SystemParameter.ValueEn, BaseUnitCount = incidentReportDetail.ItemProfile.BaseUnit, CostPrice = incidentReportDetail.ItemProfile.CostPrice, ItemNameAr = incidentReportDetail.ItemProfile.ItemNameSl, FlavourAr = incidentReportDetail.ItemProfile.FlavourSl, ItemType = incidentReportDetail.ItemProfile.Category.BrandParamType.ValueEn + "-" + incidentReportDetail.ItemProfile.Category.GroupParamType.ValueEn, IsOfferItem = incidentReportDetail.ItemProfile.IsOfferItem == true ? "Yes" : "No", PreviousCostPrice = incidentReportDetail.ItemProfile.PreviousCostPrice, AverageCostPrice = incidentReportDetail.ItemProfile.AverageCostPrice, IsActiveItem = incidentReportDetail.ItemProfile.IsActive == true ? "Yes" : "No" }; incidentAc.ItemDetails = itemOfferDetail; if (isAllowToAccessAllBranch) { incidentAc.IsCurrentUser = true; } else { if (incidentReportDetail.BranchId == userDetail.BranchId) { incidentAc.IsCurrentUser = true; } } var workflowCollection = new List <WorkFlowActionAc>(); if (incidentReportDetail.RecordId != null) { foreach (var workflowInfo in _workFLowLogContext.Fetch(x => x.RecordId == incidentReportDetail.RecordId).ToList()) { var workFlowActionAc = new WorkFlowActionAc(); workFlowActionAc.Stage = workflowInfo.Stage; workFlowActionAc.Action = workflowInfo.Action; workFlowActionAc.WorkFlowActionId = workflowInfo.Id; workFlowActionAc.RoleName = workflowInfo.RoleDetails.RoleName; workFlowActionAc.Comment = workflowInfo.Comments; workFlowActionAc.ActionDate = workflowInfo.CreatedDateTime.ToString("dd/MM/yyyy hh:mm");; var userNames = _userDetailContext.FirstOrDefault(x => x.UserId == workflowInfo.UserId); if (userNames != null) { workFlowActionAc.UserName = userNames.UserName; } workflowCollection.Add(workFlowActionAc); } incidentAc.WorkFlowAction = workflowCollection.OrderBy(x => x.WorkFlowActionId); var workFLowLastDetails = _workFLowLogContext.Fetch(x => x.RecordId == incidentReportDetail.RecordId).ToList().Last(); if (incidentReportDetail.IsReject) { var workFlowCurrentDetails = _workFlowDetailContext.FirstOrDefault(x => x.Id == workFLowLastDetails.WorkFlowDetail.ParentActivityId); if (workFlowCurrentDetails != null) { WorkFlowDetail workDetailsById = _workFlowDetailContext.FirstOrDefault(x => x.Id == workFlowCurrentDetails.ParentActivityId && x.AssignedId == userDetail.RoleId); if (workDetailsById != null) { incidentAc.IsReview = workDetailsById.IsReview; incidentAc.IsApproval = workDetailsById.IsApproval; } } } else { var workFlowCurrentDetails = _workFlowDetailContext.FirstOrDefault(x => x.Id == workFLowLastDetails.WorkFlowId && x.AssignedId == userDetail.RoleId); if (workFlowCurrentDetails != null) { incidentAc.IsReview = workFlowCurrentDetails.IsReview; incidentAc.IsApproval = workFlowCurrentDetails.IsApproval; } } } return(incidentAc); } catch (Exception ex) { _errorLog.LogException(ex); throw; } }