Exemplo n.º 1
0
 /// <summary>
 /// this method is used for adding ICR.- JJ
 /// </summary>
 /// <param name="itemChangedDetail">object of ItemChangedDetailsAC</param>
 /// <param name="user">object of UserDetail</param>
 /// <param name="company"></param>
 /// <param name="WorkFlowId"></param>
 /// <returns>status</returns>
 public string SaveICR(ItemChangedDetailsAC itemChangedDetail, UserDetail user, CompanyDetail company, int?WorkFlowId)
 {
     try
     {
         var ParentRecordId = 0;
         if (itemChangedDetail.IsInDirect)
         {
             ParentRecordId = (int)itemChangedDetail.ParentRecordId;
             itemChangedDetail.IsPOItemIcr = true;
         }
         else
         {
             var workFlowLog = _IWorkFlowDetailsRepository.GetInitiationActionWorkFlow(StringConstants.ItemChangeRequest, StringConstants.InitiateICR, user, company, itemChangedDetail, itemChangedDetail.Comment, itemChangedDetail);
             if (workFlowLog != null)
             {
                 WorkFlowLog log = (WorkFlowLog)workFlowLog.Item1;
                 ParentRecordId = log.RecordId;
                 WorkFlowDetail WorkFlow = (WorkFlowDetail)workFlowLog.Item2;
                 WorkFlowId = WorkFlow.Id;
             }
             else
             {
                 return(StringConstants.WorkFlowNotCreated);
             }
         }
         return(AddICR(itemChangedDetail, ParentRecordId, WorkFlowId, company, user));
     }
     catch (Exception ex)
     {
         _errorLog.LogException(ex);
         throw;
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// This method is used for cancel supplier purchase order in database. - JJ
        /// </summary>
        /// <param name="Comment">Comment of the person who cancels</param>
        /// <param name="RecordId">Id of Parent Record</param>
        /// <param name="userName"> Currently logged in user's username </param>
        /// <returns>null</returns>
        public string CancelSupplierPO(string Comment, int RecordId, string userName)
        {
            var currentUser = _userDetailContext.First(x => x.UserName == userName && x.IsDelete == false);
            var spo         = new SupplierPurchaseOrder();

            if (_supplierPOContext.Fetch(x => x.RecordId == RecordId).Any())
            {
                spo = _supplierPOContext.First(x => x.RecordId == RecordId);
            }
            if (spo != null)
            {
                var log = _workFlowLogContext.Fetch(x => x.RecordId == RecordId).ToList().Last();
                if (log.WorkFlowDetail.AssignedId == currentUser.RoleId)
                {
                    if (_workFlowContext.Fetch(x => x.Activity.Name == StringConstants.Review && x.ParentActivityId == log.WorkFlowId).Any())
                    {
                        var activityWorkFlow = _workFlowContext.FirstOrDefault(x => x.Activity.Name == StringConstants.Review && x.ParentActivityId == log.WorkFlowId);
                        Comment = Comment == "." ? "" : Comment;

                        var workFlowLog = new WorkFlowLog
                        {
                            Comments        = Comment,
                            CreatedDateTime = DateTime.UtcNow,
                            RecordId        = RecordId,
                            RoleId          = currentUser.RoleId,
                            UserId          = currentUser.UserId,
                            WorkFlowId      = activityWorkFlow.Id,
                            Action          = "Canceled",
                            Stage           = "" + currentUser.RoleName + " " + activityWorkFlow.Activity.Name
                        };
                        _workFlowLogContext.Add(workFlowLog);
                        _workFlowLogContext.SaveChanges();
                        SaveSupplierPurchaseOrderLog("Cancelled", Comment, spo.Id, workFlowLog.RecordId, currentUser.RoleName, "" + currentUser.RoleName + " " + activityWorkFlow.Activity.Name, currentUser.UserName);

                        spo.IsCanceled       = true;
                        spo.IsCancelApproved = false;
                        spo.ModifiedDateTime = DateTime.UtcNow;
                        _supplierPOContext.Update(spo);
                        _supplierPOContext.SaveChanges();
                        return("ok");
                    }
                    else
                    {
                        return(StringConstants.WorkFlowNotCreated);
                    }
                }
                else
                {
                    return(StringConstants.WorkFlowNotCreated);
                }
            }
            else
            {
                return(StringConstants.PONotFound);
            }
        }
        private DomainModel.Models.IncidentReport.PosIncidentReport SaveIncidentReportDetails(DomainModel.Models.IncidentReport.PosIncidentReport incidentReportInfo, WorkFlowDetail activityWorkFlow, string comment, UserDetail userDetail)
        {
            try
            {
                if (incidentReportInfo != null)
                {
                    ParentRecord parentRecord = new ParentRecord();
                    parentRecord.BranchId          = incidentReportInfo.BranchId;
                    parentRecord.CreatedDateTime   = DateTime.UtcNow;
                    parentRecord.InitiationComment = comment;
                    parentRecord.InitiationDate    = DateTime.UtcNow;
                    parentRecord.ModificationDate  = DateTime.UtcNow;
                    parentRecord.InitiatorId       = userDetail.UserId;
                    parentRecord.ModifiedUserId    = userDetail.UserId;
                    parentRecord.WorkFlowId        = activityWorkFlow.Id;
                    _parentRecordContext.Add(parentRecord);
                    _parentRecordContext.SaveChanges();

                    if (parentRecord.Id != 0)
                    {
                        WorkFlowLog workFlowLog = new WorkFlowLog();
                        workFlowLog.Comments        = comment;
                        workFlowLog.CreatedDateTime = DateTime.UtcNow;
                        workFlowLog.RecordId        = parentRecord.Id;
                        workFlowLog.RoleId          = userDetail.RoleId;
                        workFlowLog.UserId          = userDetail.UserId;
                        workFlowLog.WorkFlowId      = activityWorkFlow.Id;
                        workFlowLog.Action          = StringConstants.InitiateAction;
                        workFlowLog.Stage           = (userDetail.RoleName) + " " + (activityWorkFlow.Activity != null ? activityWorkFlow.Activity.Name : "");
                        _workFLowLogContext.Add(workFlowLog);
                        _workFLowLogContext.SaveChanges();

                        if (workFlowLog.Id != 0)
                        {
                            incidentReportInfo.IsProcess        = false;
                            incidentReportInfo.RecordId         = parentRecord.Id;
                            incidentReportInfo.ModifiedDateTime = DateTime.UtcNow;
                            _posIncidentReportDataRepository.Update(incidentReportInfo);
                            _posIncidentReportDataRepository.SaveChanges();
                        }
                    }
                    return(incidentReportInfo);
                }
                else
                {
                    return(null);
                }
            }
            catch (Exception ex)
            {
                _errorLog.LogException(ex);
                throw;
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// This method is used for submitting already saved supplier purchase order. - JJ
        /// </summary>
        /// <param name="SupplierPOId">Id of SupplierPO </param>
        /// <param name="Comment">Comment of the initiator</param>
        /// <param name="company">Object of CompanyDetail</param>
        /// <param name="userName">currently logged in user's name</param>
        /// <returns>status</returns>
        public string SubmitSupplierPO(int SupplierPOId, string Comment, string userName, CompanyDetail company)
        {
            try
            {
                var  log         = new WorkFlowLog();
                bool IsApproved  = false;
                var  currentUser = _userDetailContext.First(x => x.UserName == userName && x.IsDelete == false);
                var  supplierPO  = _supplierPOContext.Find(SupplierPOId);

                if (!supplierPO.IsSubmitted)
                {
                    var workFlowLog = _IWorkFlowDetailsRepository.GetInitiationActionWorkFlow(StringConstants.SupplierPurchaseOrder, StringConstants.CreateSupplierPurchaseOrder, currentUser, company, supplierPO, Comment, supplierPO);
                    if (workFlowLog != null)
                    {
                        log = (WorkFlowLog)workFlowLog.Item1;
                        supplierPO.RecordId = log.RecordId;
                    }
                    else
                    {
                        return(StringConstants.WorkFlowNotCreated);
                    }

                    var activityWorkFlow = _workFlowContext.FirstOrDefault(x => x.Id == log.WorkFlowId);
                    if (!activityWorkFlow.NextActivity.IsClosed)
                    {
                        IsApproved = false;
                    }
                    else
                    {
                        IsApproved = true;
                    }

                    supplierPO.ModifiedDateTime = DateTime.UtcNow;
                    supplierPO.IsApproved       = IsApproved;
                    supplierPO.IsSubmitted      = true;
                    _supplierPOContext.Update(supplierPO);
                    _supplierPOContext.SaveChanges();

                    _supplierPOWorkListContext.SaveSupplierPurchaseOrderLog(log.Action, Comment, supplierPO.Id, log.RecordId, currentUser.RoleName, log.Stage, currentUser.UserName);
                    return("ok");
                }
                else
                {
                    return("Purchase Order is already submitted");
                }
            }
            catch (Exception ex)
            {
                _errorLog.LogException(ex);
                throw;
            }
        }
 ///<summary>
 /// This method used for Approve Item Offer. -An
 /// </summary>
 /// <param name="itemOffer"></param>
 /// <returns>if approve suceesfully so pass true and other wise false</returns>
 public bool ApproveItemOffer(WorkFlowLog workFlowLog)
 {
     try
     {
         _iWorkFlowLogContext.Add(workFlowLog);
         _iWorkFlowLogContext.SaveChanges();
         return(true);
     }
     catch (Exception ex)
     {
         _errorLog.LogException(ex);
         throw;
     }
 }
 /// <summary>
 /// This method used for insert into WorkFlowLog table and return primary key. -An
 /// </summary>
 /// <param name="workFlowLog"></param>
 /// <returns></returns>
 public int AddWorkFlowLogs(WorkFlowLog workFlowLog)
 {
     try
     {
         _iWorkFlowLogContext.Add(workFlowLog);
         _iWorkFlowLogContext.SaveChanges();
         return(workFlowLog.Id);
     }
     catch (Exception ex)
     {
         _errorLog.LogException(ex);
         throw;
     }
 }
Exemplo n.º 7
0
 /// <summary>
 /// this method is used for updating ICR.- JJ
 /// </summary>
 /// <param name="itemChangedDetail">object of ItemChangedDetailsAC</param>
 /// <param name="user">object of UserDetail</param>
 /// <param name="company">object of CompanyDetail</param>
 /// <param name="RecordId">Id of Parent Record</param>
 /// <return>status</return>
 public string UpdateICR(ItemChangedDetailsAC itemChangedDetail, UserDetail user, CompanyDetail company, int RecordId)
 {
     try
     {
         var log          = _workFlowLogContext.Fetch(x => x.RecordId == RecordId).ToList().Last();
         var workFlowLog  = new WorkFlowLog();
         var profitMargin = _itemProfileContext.Fetch(x => x.Id == itemChangedDetail.ItemId).FirstOrDefault().ProfitMargin;
         var total        = (itemChangedDetail.ModifyingCostPrice * (100 + profitMargin)) / 100;
         itemChangedDetail.CalculatedCostPrice = total;
         if (itemChangedDetail.Comment == ".")
         {
             itemChangedDetail.Comment = null;
         }
         if (log.WorkFlowDetail.AssignedId == user.RoleId)
         {
             if (itemChangedDetail.IsResubmit)
             {
                 workFlowLog = _IWorkFlowDetailsRepository.GetResubmitActionWorkFlow(RecordId, itemChangedDetail, itemChangedDetail, StringConstants.ReSubmitedAction, itemChangedDetail.Comment, user);
             }
             else
             {
                 workFlowLog = _IWorkFlowDetailsRepository.GetResubmitActionWorkFlow(RecordId, itemChangedDetail, itemChangedDetail, StringConstants.EditedAction, itemChangedDetail.Comment, user);
             }
             if (workFlowLog != null)
             {
                 var icrDetail = _icrDetailContext.Fetch(x => x.RecordId == RecordId).FirstOrDefault();
                 icrDetail.IsReturned           = false;
                 icrDetail.IsPriceChangeRequest = itemChangedDetail.IsPriceChangeRequest;
                 icrDetail.ModifiedDateTime     = DateTime.UtcNow;
                 _icrDetailContext.Update(icrDetail);
                 _icrDetailContext.SaveChanges();
                 bool modifyingCostPriceEditable = icrDetail.SPOItemId != null ? false : true;
                 return(AddICRPriceQuantity(itemChangedDetail, icrDetail.ItemId, icrDetail.Id, true, modifyingCostPriceEditable));
             }
             else
             {
                 return(StringConstants.WorkFlowNotCreated);
             }
         }
         else
         {
             return(StringConstants.WorkFlowNotCreated);
         }
     }
     catch (Exception ex)
     {
         _errorLog.LogException(ex);
         throw;
     }
 }
 /// <summary>
 /// This method used for get work flow by record id. -An
 /// </summary>
 /// <param name="recordId"></param>
 /// <returns></returns>
 public List <WorkFlowDetail> GetWorkFlowDetailByRecordId(int recordId, int companyId)
 {
     try
     {
         List <WorkFlowDetail> listOfWorkFlowDetail = new List <WorkFlowDetail>();
         WorkFlowLog           workFlowLogObject    = _iWorkFlowLogContext.Fetch(x => x.RecordId == recordId).OrderByDescending(x => x.CreatedDateTime).FirstOrDefault();
         if (workFlowLogObject != null)
         {
             listOfWorkFlowDetail = _iWorkFlowDetailContext.Fetch(x => x.ParentActivityId == workFlowLogObject.WorkFlowId && x.CompanyId == companyId).ToList();
         }
         return(listOfWorkFlowDetail);
     }
     catch (Exception ex)
     {
         _errorLog.LogException(ex);
         throw;
     }
 }
        /// <summary>
        /// This method used for get list Of Incident Report WorkList. -An
        /// </summary>
        /// <returns></returns>
        public List <IncidentReportWorkListAC> listOfIncidentReportWorkListAC(int companyId)
        {
            try
            {
                List <IncidentReportWorkListAC> listOfIncidentReportWorkFlowList = new List <IncidentReportWorkListAC>();
                IncidentReport incidentReport = _incidentReportContext.FirstOrDefault(x => x.CompanyId == companyId);
                if (incidentReport != null)
                {
                    List <CashierIncidentReport> listOfCashierIncidentReport = _cashierIncidentReportCotext.Fetch(x => (x.OperationCounter >= incidentReport.OperationCounter || x.AmountLimit >= incidentReport.AmountLimit) && x.UserDetail.Branch.CompanyId == incidentReport.CompanyId).ToList();
                    foreach (var cashierIncidentReport in listOfCashierIncidentReport)
                    {
                        IncidentReportWorkListAC incidentReportWorkListAc = new IncidentReportWorkListAC();
                        incidentReportWorkListAc.Id          = cashierIncidentReport.Id;
                        incidentReportWorkListAc.CashierId   = cashierIncidentReport.UserDetail.Id;
                        incidentReportWorkListAc.CashierName = cashierIncidentReport.UserDetail.UserName;

                        if (cashierIncidentReport.ParentRecord != null)
                        {
                            WorkFlowLog workFlowLog = _workFlowLogContext.Fetch(x => x.RecordId == cashierIncidentReport.ParentRecord.Id).OrderBy(x => x.CreatedDateTime).FirstOrDefault();
                            if (workFlowLog != null)
                            {
                                incidentReportWorkListAc.Comment = workFlowLog.Comments;
                            }
                        }
                        incidentReportWorkListAc.ReachedDateTime = cashierIncidentReport.CreatedDateTime;
                        incidentReportWorkListAc.BranchName      = cashierIncidentReport.UserDetail.Branch.Name;
                        incidentReportWorkListAc.BranchId        = cashierIncidentReport.UserDetail.BranchId != null?Convert.ToInt32(cashierIncidentReport.UserDetail.BranchId) : 0;

                        listOfIncidentReportWorkFlowList.Add(incidentReportWorkListAc);
                    }
                }
                return(listOfIncidentReportWorkFlowList);
            }
            catch (Exception ex)
            {
                _errorLog.LogException(ex);
                throw;
            }
        }
 private WorkFlowLog SaveWorkFlowDetails(WorkFlowDetail workFlowCurrentDetails, DomainModel.Models.IncidentReport.PosIncidentReport incidentReportInfo, UserDetail userDetails, string comment, string action)
 {
     try
     {
         WorkFlowLog workFlowLog = new WorkFlowLog();
         workFlowLog.Comments        = comment;
         workFlowLog.CreatedDateTime = DateTime.UtcNow;
         workFlowLog.RecordId        = (int)incidentReportInfo.RecordId;
         workFlowLog.RoleId          = userDetails.RoleId;
         workFlowLog.UserId          = userDetails.UserId;
         workFlowLog.WorkFlowId      = workFlowCurrentDetails.Id;
         workFlowLog.Action          = action;
         workFlowLog.Stage           = (userDetails.RoleName) + " " + (workFlowCurrentDetails.Activity != null ? workFlowCurrentDetails.Activity.Name : "");
         _workFLowLogContext.Add(workFlowLog);
         _workFLowLogContext.SaveChanges();
         return(workFlowLog);
     }
     catch (Exception ex)
     {
         _errorLog.LogException(ex);
         throw;
     }
 }
Exemplo n.º 11
0
        /// <summary>
        /// This method is used for receive an item of SPO. This is a private method called by ReceiveSPOItem - JJ
        /// </summary>
        /// <param name="SupplierItemAC">object of SupplierItemAC</param>
        /// <param name="currentUser">object of UserDetail</param>
        /// <param name="company">object of CompanyDetail</param>
        private int Receive(SupplierItemAC SupplierItemAC, UserDetail currentUser, CompanyDetail company)
        {
            PurchaseOrderItem poItem = _purchaseOrderItemContext.FirstOrDefault(x => x.ItemId == SupplierItemAC.ItemId && x.PurchaseOrderId == SupplierItemAC.PurchaseOrderId && x.SupplierPurchaseOrder.IsApproved && x.SupplierPurchaseOrder.IsSend);
            var  status     = "";
            bool icrCreated = false;

            poItem.ReceivingCostPrice = SupplierItemAC.ReceiveCostPrice;
            poItem.ReceivingQuantity  = SupplierItemAC.ReceiveQuantity;
            poItem.BillCostPrice      = SupplierItemAC.BillCostPrice;
            if (SupplierItemAC.ReceiveQuantity > SupplierItemAC.OrderQuantity)
            {
                poItem.SPOReceivingStatus = SPOReceivingStatus.PartiallyReceived;
            }

            var workflowLog = _iWorkFlowDetailsRepository.GetInitiationActionWorkFlow(StringConstants.SPOReceiving, StringConstants.ReceiveSPO, currentUser, company, poItem, null, poItem);

            if (workflowLog != null)
            {
                IcrDetail prevICR = _icrDetailContext.FirstOrDefault(x => x.SPOItemId == poItem.Id && !x.IsDeleted);
                if (prevICR != null)
                {
                    _iICRRepository.DeleteICR(prevICR.Id);
                }

                WorkFlowLog log            = (WorkFlowLog)workflowLog.Item1;
                var         workFlowDetail = (WorkFlowDetail)workflowLog.Item2;

                if (workFlowDetail.NextActivity.Id == 3)
                {
                    if (poItem.OrderQuantity > SupplierItemAC.ReceiveQuantity)
                    {
                        poItem.SPOReceivingStatus = SPOReceivingStatus.PartiallyReceived;
                    }
                    else
                    {
                        poItem.SPOReceivingStatus = SPOReceivingStatus.Received;
                    }
                }
                else
                {
                    poItem.SPOReceivingStatus = SPOReceivingStatus.NotReceived;
                }
                if (workFlowDetail.ParentPermission.Name == StringConstants.ItemChangeRequest && poItem.SPOReceivingStatus == SPOReceivingStatus.NotReceived)
                {
                    icrCreated = true;

                    ItemChangedDetailsAC itemChange = new ItemChangedDetailsAC
                    {
                        IsPOItemIcr          = true,
                        IsPriceChangeRequest = true,
                        ItemId              = SupplierItemAC.ItemId,
                        ModifyingCostPrice  = poItem.ReceivingCostPrice,
                        ModifyingSellPrice  = poItem.ItemProfile.SellPrice,
                        ModifyingSellPriceA = poItem.ItemProfile.SellPriceA,
                        ModifyingSellPriceB = poItem.ItemProfile.SellPriceB,
                        ModifyingSellPriceC = poItem.ItemProfile.SellPriceC,
                        ModifyingSellPriceD = poItem.ItemProfile.SellPriceD,
                        POItemId            = poItem.Id,
                        RequestedDate       = DateTime.UtcNow,
                        ParentRecordId      = log.RecordId,
                        IsInDirect          = true
                    };
                    status = _iICRRepository.SaveICR(itemChange, currentUser, company, workFlowDetail.Id);
                }
                if (status == "ok")
                {
                    var newICR = _icrDetailContext.Fetch(x => x.SPOItemId == poItem.Id && !x.IsDeleted).ToList().LastOrDefault();
                    if (newICR != null)
                    {
                        poItem.ICRDetailId = newICR.Id;
                        if (newICR.IsApproved && poItem.SPOReceivingStatus != SPOReceivingStatus.PartiallyReceived)
                        {
                            poItem.SPOReceivingStatus = SPOReceivingStatus.Received;
                        }
                    }
                }
                poItem.ModifiedDateTime = DateTime.UtcNow;
                _purchaseOrderItemContext.Update(poItem);
                _purchaseOrderItemContext.SaveChanges();
                if (icrCreated)
                {
                    return(300);
                }
                else
                {
                    return((int)poItem.SPOReceivingStatus);
                }
            }
            else
            {
                return(400);
            }
        }
Exemplo n.º 12
0
        /// <summary>
        /// This method is used for insert new supplier purchase order in database. - JJ
        /// </summary>
        /// <param name="supplierPO"> object of SupplierPOAC</param>
        /// <param name="company">object of Company</param>
        /// <param name="userName">current user's username</param>
        /// <returns>status</returns>
        public string SaveSupplierPO(SupplierPOAC supplierPO, string userName, CompanyDetail company)
        {
            try
            {
                var    log                 = new WorkFlowLog();
                var    currentUser         = _userDetailContext.First(x => x.UserName == userName && x.IsDelete == false);
                var    companyConfig       = _companyConfigurationContext.First(x => x.CompanyId == company.Id);
                var    sponumber           = companyConfig.SPOInvoiceNo;
                bool   IsApproved          = false;
                bool   IsConfirmed         = false;
                bool   IsCanceled          = false;
                bool   IsRejected          = false;
                bool   IsPartiallyReceived = false;
                string ponumber            = PurchaseOrderNumberGenerator(sponumber, 4);
                if (supplierPO.IsSubmitted)
                {
                    var workFlowLog = _IWorkFlowDetailsRepository.GetInitiationActionWorkFlow(StringConstants.SupplierPurchaseOrder, StringConstants.CreateSupplierPurchaseOrder, currentUser, company, supplierPO, supplierPO.InitiationComment, supplierPO);
                    if (workFlowLog != null)
                    {
                        log = (WorkFlowLog)workFlowLog.Item1;
                        supplierPO.ParentRecordId = log.RecordId;
                    }
                    else
                    {
                        return(StringConstants.WorkFlowNotCreated);
                    }
                    var activityWorkFlow = _workFlowContext.FirstOrDefault(x => x.Id == log.WorkFlowId);
                    if (!activityWorkFlow.NextActivity.IsClosed)
                    {
                        IsApproved = false;
                    }
                    else
                    {
                        IsApproved = true;
                    }
                }

                var  supplierType = _paramTypeContext.Fetch(x => x.Param.Key == StringConstants.SupplierType);
                bool isCredit     = false;
                foreach (var type in supplierType)
                {
                    if (type.Id == supplierPO.SupplierTypeId && type.ValueEn == StringConstants.Credit)
                    {
                        isCredit = true;
                    }
                    else
                    {
                        isCredit = false;
                    }
                }

                var supplierPurchaseOrder = new SupplierPurchaseOrder
                {
                    UserId              = currentUser.Id,
                    RecordId            = supplierPO.ParentRecordId,
                    SupplierId          = supplierPO.SupplierId,
                    InitiationBranchId  = supplierPO.InitiationBranchId,
                    IsApproved          = IsApproved,
                    IsConfirmed         = IsConfirmed,
                    IsNotProcessed      = true,
                    IsRejected          = IsRejected,
                    IsCanceled          = IsCanceled,
                    IsPartiallyReceived = IsPartiallyReceived,
                    IsSend              = false,
                    IsSubmitted         = supplierPO.IsSubmitted,
                    DueDate             = supplierPO.DueDate,
                    CreatedDateTime     = DateTime.UtcNow,
                    CreditDaysLimit     = supplierPO.SupplierDaysLimit,
                    IsCreditPayment     = isCredit,
                    UpdatedDate         = DateTime.UtcNow,
                    PurchaseOrderNumber = ponumber
                };
                _supplierPOContext.Add(supplierPurchaseOrder);
                _supplierPOContext.SaveChanges();

                if (supplierPO.IsSubmitted)
                {
                    _supplierPOWorkListContext.SaveSupplierPurchaseOrderLog(log.Action, supplierPO.InitiationComment, supplierPurchaseOrder.Id, log.RecordId, currentUser.RoleName, log.Stage, currentUser.UserName);
                }

                foreach (var branch in supplierPO.SPOBranch)
                {
                    var spoBranch = new PurchaseOrderBranch
                    {
                        CreatedDateTime = DateTime.UtcNow,
                        BranchId        = branch.Id,
                        PurchaseOrderId = supplierPurchaseOrder.Id
                    };
                    _purchaseOrderBranchContext.Add(spoBranch);
                    _purchaseOrderBranchContext.SaveChanges();
                }
                foreach (var item in supplierPO.SupplierItem)
                {
                    var poItem = new PurchaseOrderItem
                    {
                        CreatedDateTime      = DateTime.UtcNow,
                        FreeQuantity         = item.FreeQuantity,
                        ItemId               = item.ItemId,
                        OrderCostPrice       = item.OrderCostPrice,
                        OrderQuantity        = item.OrderQuantity,
                        ReceivingCostPrice   = item.OrderCostPrice,
                        BillCostPrice        = item.OrderCostPrice,
                        ReceivingQuantity    = item.OrderQuantity,
                        SystemParameterId    = item.UnitParamTypeId,
                        PercentageDiscount   = item.PercentageDiscount,
                        IsPercentageDiscount = true,
                        PurchaseOrderId      = supplierPurchaseOrder.Id,
                        ReceivingDate        = supplierPO.DueDate,
                        UpdatedDate          = DateTime.UtcNow,
                        SPOReceivingStatus   = SPOReceivingStatus.NotReceived
                    };
                    _purchaseOrderItemContext.Add(poItem);
                    _purchaseOrderItemContext.SaveChanges();
                }
                return(StringConstants.SPOCreated);
            }
            catch (Exception ex)
            {
                _errorLog.LogException(ex);
                throw;
            }
        }
        /// <summary>
        /// This method is used for save new  supplier return request in database. - JJ
        /// </summary>
        /// <param name="SupplierReturnRequest">object of SupplierReturnRequest</param>
        /// <param name="company">object of CompanyDetail</param>
        /// <param name="user">object of UserDetail</param>
        /// <returns>object of SupplierReturnRequest</returns>

        public SupplierReturnRequest SaveSupplierReturnRequest(SupplierReturnRequest SupplierReturnRequest, UserDetail user, CompanyDetail company)
        {
            try
            {
                var status = CheckSupplierConditions(SupplierReturnRequest.SupplierId, SupplierReturnRequest.SupplierReturnItemAC);
                if (status == "ok")
                {
                    var ParentRecordId = 0;
                    var workFlowLog    = _IWorkFlowDetailsRepository.GetInitiationActionWorkFlow(StringConstants.SupplierReturnRequest, StringConstants.InitiateSupplierReturnRequest, user, company, null, SupplierReturnRequest.InitiationComment, null);
                    if (workFlowLog != null)
                    {
                        WorkFlowLog    log            = (WorkFlowLog)workFlowLog.Item1;
                        WorkFlowDetail workFlowDetail = (WorkFlowDetail)workFlowLog.Item2;
                        ParentRecordId = log.RecordId;
                        var requestNo            = RequestNumberGenerator(company.Id);
                        var supplierReturnDetail = new SupplierReturnDetail
                        {
                            CreatedDateTime   = DateTime.UtcNow,
                            IsRejected        = false,
                            IsDeleted         = false,
                            RecordId          = ParentRecordId,
                            LastActivityDate  = DateTime.UtcNow,
                            SupplierId        = SupplierReturnRequest.SupplierId,
                            RequestNo         = requestNo,
                            BranchId          = SupplierReturnRequest.BranchId,
                            InitiatorId       = user.Id,
                            InitiationComment = SupplierReturnRequest.InitiationComment
                        };
                        _supplierReturnDetailContext.Add(supplierReturnDetail);
                        _supplierReturnDetailContext.SaveChanges();

                        foreach (var item in SupplierReturnRequest.SupplierReturnItemAC)
                        {
                            var supplierReturnItem = new SupplierReturnItem
                            {
                                CostPrice        = item.CostPrice,
                                CreatedDateTime  = DateTime.UtcNow,
                                ItemId           = item.ItemId,
                                ReturnQuantity   = item.ReturnQuantity,
                                SupplierReturnId = supplierReturnDetail.Id,
                                ReturnCauseId    = item.ReturnCauseId
                            };
                            _supplierReturnItemContext.Add(supplierReturnItem);
                            _supplierReturnItemContext.SaveChanges();

                            var itemProfile = _itemProfileContext.Find(item.ItemId);
                            itemProfile.IsSupplierReturnRequestGenerated = true;
                            _itemProfileContext.Update(itemProfile);
                            _itemProfileContext.SaveChanges();
                        }
                        SupplierReturnRequest.SupplierReturnId = supplierReturnDetail.Id;
                        var companyid = _branchDetailContext.Find(supplierReturnDetail.BranchId).CompanyId;
                        if (workFlowDetail.NextActivity.IsClosed)
                        {
                            var outcome = _ISupReturnWorkListRepository.IssueCreditNote(supplierReturnDetail.Id, supplierReturnDetail.BranchId, companyid, supplierReturnDetail.InitiationComment);
                            if (outcome)
                            {
                                SupplierReturnRequest.Status = "print";
                            }
                            else
                            {
                                SupplierReturnRequest.Status = "Error in Issueing Credit Note";
                            }
                            return(SupplierReturnRequest);
                        }
                        else
                        {
                            SupplierReturnRequest.Status = "ok";
                            return(SupplierReturnRequest);
                        }
                    }
                    else
                    {
                        SupplierReturnRequest.Status = StringConstants.WorkFlowNotCreated;
                        return(SupplierReturnRequest);
                    }
                }
                else
                {
                    SupplierReturnRequest.Status = status;
                    return(SupplierReturnRequest);
                }
            }
            catch (Exception ex)
            {
                _errorLog.LogException(ex);
                throw;
            }
        }
        /// <summary>
        /// This method is used for update supplier return request in database. - JJ
        /// </summary>
        /// <param name="SupplierReturnRequest">object of SupplierReturnRequest</param>
        /// <param name="company">object of CompanyDetail</param>
        /// <param name="user">object of UserDetail</param>
        /// <returns>status</returns>
        public string UpdateSupplierReturnRequest(SupplierReturnRequest SupplierReturnRequest, UserDetail user, CompanyDetail company)
        {
            try
            {
                var workFlowLog    = new WorkFlowLog();
                var supplierReturn = _supplierReturnDetailContext.Fetch(x => x.RecordId == SupplierReturnRequest.RecordId).FirstOrDefault();
                if (supplierReturn.IsRejected || supplierReturn.IsDeleted)
                {
                    if (supplierReturn.IsRejected)
                    {
                        return("Supplier Return Request is Rejected. You cannot Resubmit or Edit it");
                    }
                    else
                    {
                        return("Supplier Return Request is Deleted. You cannot Resubmit or Edit it");
                    }
                }
                else
                {
                    var status = CheckSupplierConditions(SupplierReturnRequest.SupplierId, SupplierReturnRequest.SupplierReturnItemAC);
                    if (status == "ok")
                    {
                        if (SupplierReturnRequest.IsResubmit)
                        {
                            workFlowLog = _IWorkFlowDetailsRepository.GetResubmitActionWorkFlow(SupplierReturnRequest.RecordId, SupplierReturnRequest, SupplierReturnRequest, StringConstants.ReSubmitedAction, SupplierReturnRequest.Comment, user);
                        }
                        else
                        {
                            workFlowLog = _IWorkFlowDetailsRepository.GetResubmitActionWorkFlow(SupplierReturnRequest.RecordId, SupplierReturnRequest, SupplierReturnRequest, StringConstants.EditedAction, SupplierReturnRequest.InitiationComment, user);
                        }
                        if (workFlowLog != null)
                        {
                            supplierReturn.SupplierId       = SupplierReturnRequest.SupplierId;
                            supplierReturn.LastActivityDate = DateTime.UtcNow;
                            supplierReturn.ModifiedDateTime = DateTime.UtcNow;
                            _supplierReturnDetailContext.Update(supplierReturn);
                            _supplierReturnDetailContext.SaveChanges();

                            DeleteSupplierReturnItem(supplierReturn.Id);

                            foreach (var item in SupplierReturnRequest.SupplierReturnItemAC)
                            {
                                var supplierReturnItem = new SupplierReturnItem
                                {
                                    CostPrice        = item.CostPrice,
                                    CreatedDateTime  = DateTime.UtcNow,
                                    ItemId           = item.ItemId,
                                    ReturnQuantity   = item.ReturnQuantity,
                                    SupplierReturnId = SupplierReturnRequest.SupplierReturnId,
                                    ReturnCauseId    = item.ReturnCauseId
                                };
                                _supplierReturnItemContext.Add(supplierReturnItem);
                                _supplierReturnItemContext.SaveChanges();

                                var itemProfile = _itemProfileContext.Find(item.ItemId);
                                itemProfile.IsSupplierReturnRequestGenerated = true;
                                itemProfile.ModifiedDateTime = DateTime.UtcNow;
                                _itemProfileContext.Update(itemProfile);
                                _itemProfileContext.SaveChanges();
                            }
                            return("ok");
                        }
                        else
                        {
                            return(StringConstants.WorkFlowNotCreated);
                        }
                    }
                    else
                    {
                        return(status);
                    }
                }
            }
            catch (Exception ex)
            {
                _errorLog.LogException(ex);
                throw;
            }
        }
Exemplo n.º 15
0
        /// <summary>
        /// This method is used for approving cancel supplier purchase order in database. - JJ
        /// </summary>
        /// <param name="Comment">Comment of the person who approves cancel</param>
        /// <param name="RecordId">Id of Parent Record</param>
        /// <param name="userName"> Currently logged in user's username </param>
        /// <returns>null</returns>
        public void ApproveCancelSupplierPO(string Comment, int RecordId, string userName, int Status)
        {
            var spo = new SupplierPurchaseOrder();

            if (_supplierPOContext.Fetch(x => x.RecordId == RecordId).Any())
            {
                spo = _supplierPOContext.First(x => x.RecordId == RecordId);
            }
            if (spo != null)
            {
                bool isCancelApproved;
                bool approve     = Status == 1 ? true : false;
                var  currentUser = _userDetailContext.First(x => x.UserName == userName && x.IsDelete == false);
                var  log         = _workFlowLogContext.Fetch(x => x.RecordId == RecordId).ToList().Last();
                if (log.WorkFlowDetail.AssignedId == currentUser.RoleId && _workFlowContext.Fetch(x => x.Activity.Name == StringConstants.Review && x.ParentActivityId == log.WorkFlowId).Any())
                {
                    _workFlowContext.Fetch(x => x.Activity.Name == StringConstants.Review && x.ParentActivityId == log.WorkFlowId).ToList();
                    if (approve)
                    {
                        var activityWorkFlow = _workFlowContext.FirstOrDefault(x => x.Activity.Name == StringConstants.Review && x.ParentActivityId == log.WorkFlowId && x.IsApprovePanel);
                        if (Comment == ".")
                        {
                            Comment = "";
                        }
                        var workFlowLog = new WorkFlowLog
                        {
                            Comments        = Comment,
                            CreatedDateTime = DateTime.UtcNow,
                            RecordId        = RecordId,
                            RoleId          = currentUser.RoleId,
                            UserId          = currentUser.UserId,
                            WorkFlowId      = activityWorkFlow.Id,
                            Action          = "Cancel Approved",
                            Stage           = "" + currentUser.RoleName + " " + activityWorkFlow.Activity.Name
                        };
                        _workFlowLogContext.Add(workFlowLog);
                        _workFlowLogContext.SaveChanges();

                        SaveSupplierPurchaseOrderLog("Cancel Approved", Comment, spo.Id, workFlowLog.RecordId, currentUser.RoleName, "" + currentUser.RoleName + " " + activityWorkFlow.Activity.Name, currentUser.UserName);
                        isCancelApproved = (activityWorkFlow.IsApproval || activityWorkFlow.IsReview) ? false : true;

                        spo.IsCanceled       = true;
                        spo.IsCancelApproved = isCancelApproved;
                        spo.ModifiedDateTime = DateTime.UtcNow;
                        _supplierPOContext.Update(spo);
                        _supplierPOContext.SaveChanges();
                    }
                    else
                    {
                        var activityWorkFlow = _workFlowContext.FirstOrDefault(x => x.Activity.Name == StringConstants.Review && x.ParentActivityId == log.WorkFlowId && x.IsRejectPanel);
                        Comment = (Comment == ".") ? "" : Comment;
                        var workFlowLog = new WorkFlowLog
                        {
                            Comments        = Comment,
                            CreatedDateTime = DateTime.UtcNow,
                            RecordId        = RecordId,
                            RoleId          = currentUser.RoleId,
                            UserId          = currentUser.UserId,
                            WorkFlowId      = activityWorkFlow.Id,
                            Action          = "Rejected Cancel",
                            Stage           = "" + currentUser.RoleName + " " + activityWorkFlow.Activity.Name
                        };
                        _workFlowLogContext.Add(workFlowLog);
                        _workFlowLogContext.SaveChanges();
                        SaveSupplierPurchaseOrderLog("Rejected Cancel", Comment, spo.Id, workFlowLog.RecordId, currentUser.RoleName, "" + currentUser.RoleName + " " + activityWorkFlow.Activity.Name, currentUser.UserName);

                        spo.IsCanceled       = false;
                        spo.IsCancelApproved = false;
                        spo.ModifiedDateTime = DateTime.UtcNow;
                        _supplierPOContext.Update(spo);
                        _supplierPOContext.SaveChanges();
                    }
                }
            }
        }
        /// <summary>
        /// This method is used for checking supplier bill list from database. - JJ
        /// </summary>
        /// <param name="PurchaseOrderId">id of PurchaseOrder</param>
        /// <returns>list of objects of SPOReceivingBillAC</returns>
        public List <SPOReceivingBillAC> CheckCondition(UserDetail currentUser, CompanyDetail company, List <SPOReceivingBillAC> SPOReceivingBill)
        {
            bool    isCashPO;
            bool    IsDiscountChanged = true;
            decimal discount          = 0M;
            bool    canBePaid         = true;

            foreach (var spobill in SPOReceivingBill)
            {
                var poItems = _purchaseOrderItemContext.Fetch(x => x.SupplierPurchaseOrder.PurchaseOrderNumber == spobill.PurchaseOrderNo && x.SPOReceivingStatus != SPOReceivingStatus.NotReceived).ToList();

                var bill = _poSupplierBillContext.FirstOrDefault(x => x.IsVerified && !x.IsPaid && x.SupplierPurchaseOrder.PurchaseOrderNumber == spobill.PurchaseOrderNo && x.Id == spobill.BillId);
                if (bill != null && bill.SupplierPurchaseOrder.IsApproved && bill.SupplierPurchaseOrder.IsReceived && bill.SupplierPurchaseOrder.IsSend && bill.SupplierPurchaseOrder.IsVerified)
                {
                    if (bill.SupplierPurchaseOrder.SupplierProfile.SupplierType.ValueEn == StringConstants.Cash)
                    {
                        isCashPO = true;
                    }
                    else
                    {
                        isCashPO = false;
                    }
                    if (!isCashPO)
                    {
                        //TODO: replace with supplier days limit
                        var suppDays = _supplierDaysLimit.Fetch(x => x.SupplierId == bill.SupplierPurchaseOrder.SupplierId).ToList();
                        if (suppDays.Any())
                        {
                            var date = DateTime.UtcNow.Subtract(bill.SupplierPurchaseOrder.UpdatedDate);
                            var days = Convert.ToInt32(Math.Round(date.TotalDays));
                            for (var i = 0; i < suppDays.Count; i++)
                            {
                                int index;
                                if (i == 0 && days < suppDays[i].Days) // no limit arrived yet
                                {
                                    IsDiscountChanged = false;
                                    break;
                                }

                                if (days == suppDays[i].Days) //in case its same days limit
                                {
                                    index = i;
                                    if (bill.PresentDiscount == suppDays[index].Discount)
                                    {
                                        IsDiscountChanged = false;
                                        break;
                                    }
                                }
                                else if (suppDays[i].Days > days || //between the days
                                         (((i + 1) <= (suppDays.Count - 1)) && suppDays[i + 1].Days >= days))
                                {
                                    index = i + 1;
                                    if (bill.PresentDiscount == suppDays[index].Discount)
                                    {
                                        IsDiscountChanged = false;
                                        break;
                                    }
                                    else
                                    {
                                        discount          = suppDays[index].Discount;
                                        IsDiscountChanged = true;
                                        break;
                                    }
                                }
                            }
                        }
                        else
                        {
                            IsDiscountChanged = false;
                        }
                        if (IsDiscountChanged && bill.PresentDiscount != discount)
                        {
                            bill.PresentDiscount = discount;
                            _poSupplierBillContext.Update(bill);
                            _poSupplierBillContext.SaveChanges();
                        }
                        else
                        {
                            IsDiscountChanged = false;
                        }
                        PurchaseOrderBranch conditions = new PurchaseOrderBranch
                        {
                            IsDiscountChanged = IsDiscountChanged
                        };
                        var workflowLog = _iWorkFlowDetailsRepository.GetInitiationActionWorkFlow(StringConstants.SPOPayment, StringConstants.PaySPO, currentUser, company, conditions, null, conditions);
                        if (workflowLog != null)
                        {
                            WorkFlowLog log            = (WorkFlowLog)workflowLog.Item1;
                            var         workFlowDetail = _workFlowContext.Find(log.WorkFlowId);
                            if (workFlowDetail.NextActivity.IsClosed)
                            {
                                spobill.IsSelected = true;
                                spobill.CanBePaid  = true;
                                if (workFlowDetail.ParentPermission.Name == StringConstants.ItemChangeRequest)
                                {
                                    ChangePrices(spobill.PurchaseOrderNo, log.RecordId, currentUser, company, true, workFlowDetail.Id);
                                    break;
                                }
                            }
                            else
                            {
                                if (workFlowDetail.ParentPermission.Name == StringConstants.ItemChangeRequest)
                                {
                                    spobill.IsSelected           = true;
                                    spobill.CanBePaid            = true;
                                    spobill.IsICRCreated         = true;
                                    spobill.IsICRAlreadyCreated  = false;
                                    spobill.IsWorkFlowNotCreated = false;
                                    spobill.IsBillNotFound       = false;
                                    ChangePrices(spobill.PurchaseOrderNo, log.RecordId, currentUser, company, true, workFlowDetail.Id);
                                    break;
                                }
                            }
                            foreach (var item in poItems)
                            {
                                if (item.ItemProfile.IsItemChangeRequestGenerated)
                                {
                                    canBePaid = false;
                                    break;
                                }
                            }
                            if (!canBePaid)
                            {
                                spobill.IsICRAlreadyCreated = true;
                            }
                        }
                        else
                        {
                            spobill.IsSelected           = false;
                            spobill.CanBePaid            = false;
                            spobill.IsICRCreated         = false;
                            spobill.IsICRAlreadyCreated  = false;
                            spobill.IsWorkFlowNotCreated = true;
                            spobill.IsBillNotFound       = false;
                        }
                    }
                    else
                    {
                        spobill.IsSelected = true;
                        spobill.CanBePaid  = true;
                    }
                }
                else
                {
                    spobill.IsSelected           = false;
                    spobill.CanBePaid            = false;
                    spobill.IsBillNotFound       = true;
                    spobill.IsICRCreated         = false;
                    spobill.IsWorkFlowNotCreated = false;
                    spobill.IsICRAlreadyCreated  = false;
                }
            }
            return(SPOReceivingBill);
        }
        public IHttpActionResult ResetIncidnetReport(int cashierId)
        {
            try
            {
                if (HttpContext.Current.User.Identity.IsAuthenticated)
                {
                    ManageIncidentReportAC       manageIncidentReportAC    = new ManageIncidentReportAC();
                    List <CashierIncidentReport> cashierIncidentReportList = _incidentReportRepository.GetCashierIncidentListByCashierId(cashierId);

                    if (cashierIncidentReportList.Count > 0 && cashierIncidentReportList[cashierIncidentReportList.Count - 1] != null)
                    {
                        var userDetial = _iUserDetailReport.GetUserDetailByUserName(HttpContext.Current.User.Identity.Name);
                        if (userDetial != null)
                        {
                            if (cashierIncidentReportList[cashierIncidentReportList.Count - 1].IsResetRequest == true)
                            {
                                var workFlowLog = _iParentRecordsRepository.GetLastWorkFlowDetaiByRecordId(Convert.ToInt32(cashierIncidentReportList[cashierIncidentReportList.Count - 1].RecordId));
                                if (workFlowLog != null)
                                {
                                    if (workFlowLog.WorkFlowDetail.IsApproval && workFlowLog.WorkFlowDetail.IsParentAction && workFlowLog.WorkFlowDetail.AssignedId == userDetial.RoleId)
                                    {
                                        manageIncidentReportAC.IsApproval = true;
                                    }
                                    return(Ok(new { result = manageIncidentReportAC }));
                                }
                            }
                            else
                            {
                                List <WorkFlowDetail> listOfWorkFlowDetail = _iParentRecordsRepository.GetWorkFlowDetailListByParent(StringConstants.IncidentReportParamenter, userDetial.Branch.CompanyId);
                                if (listOfWorkFlowDetail.Any())
                                {
                                    var activityWorkFlow = listOfWorkFlowDetail.FirstOrDefault(x => x.InitiatorId == userDetial.RoleId && x.IsParentAction);
                                    if (activityWorkFlow != null)
                                    {
                                        ParentRecord parentRecord = new ParentRecord();
                                        parentRecord.BranchId          = cashierIncidentReportList[0].UserDetail.BranchId;
                                        parentRecord.CreatedDateTime   = DateTime.UtcNow;
                                        parentRecord.WorkFlowId        = activityWorkFlow.Id;
                                        parentRecord.ModificationDate  = parentRecord.CreatedDateTime;
                                        parentRecord.InitiationDate    = parentRecord.ModificationDate;
                                        parentRecord.ModifiedUserId    = userDetial.UserId;
                                        parentRecord.InitiatorId       = parentRecord.ModifiedUserId;
                                        parentRecord.InitiationComment = "Reset Incident Report By" + userDetial.RoleName;
                                        int recordId = _iParentRecordsRepository.AddParentRecords(parentRecord);
                                        if (recordId != 0)
                                        {
                                            WorkFlowLog workFLowLogDetail = new WorkFlowLog();
                                            workFLowLogDetail.Action          = "Reset Incident Report";
                                            workFLowLogDetail.Stage           = (activityWorkFlow.Activity != null ? activityWorkFlow.Activity.Name : "") + " By" + (MerchantContext.UserDetails != null ? MerchantContext.UserDetails.RoleName : "");
                                            workFLowLogDetail.UserId          = userDetial.UserId;
                                            workFLowLogDetail.WorkFlowId      = activityWorkFlow.Id;
                                            workFLowLogDetail.RoleId          = userDetial.RoleId;
                                            workFLowLogDetail.CreatedDateTime = DateTime.UtcNow;
                                            workFLowLogDetail.RecordId        = recordId;
                                            workFLowLogDetail.Comments        = "Reset Incident Report By" + userDetial.RoleName;
                                            int workFlowId = _iParentRecordsRepository.AddWorkFlowLogs(workFLowLogDetail);
                                            if (workFlowId != 0)
                                            {
                                                foreach (var cashierIncidentReport in cashierIncidentReportList)
                                                {
                                                    cashierIncidentReport.RecordId         = recordId;
                                                    cashierIncidentReport.ModifiedDateTime = DateTime.UtcNow;
                                                    if (activityWorkFlow.IsClosed)
                                                    {
                                                        cashierIncidentReport.IsResetRequest   = true;
                                                        cashierIncidentReport.IsRefreshRequset = true;
                                                    }
                                                    else
                                                    {
                                                        manageIncidentReportAC.IsApproveByBranchSupervisor = true;
                                                        cashierIncidentReport.IsResetRequest = true;
                                                    }
                                                    _incidentReportRepository.UpdateCashierIncidentReportByCashier(cashierIncidentReport);
                                                }
                                                manageIncidentReportAC.IsAddParentRecord = true;
                                                return(Ok(new { result = manageIncidentReportAC }));
                                            }
                                        }
                                    }
                                }
                                return(Ok(new { result = "IsNotWorkFlow" }));
                            }
                        }
                        return(Ok(new { result = false }));
                    }

                    return(Ok());
                }
                else
                {
                    return(BadRequest());
                }
            }
            catch (Exception ex)
            {
                _errorLog.LogException(ex);
                throw;
            }
        }