Пример #1
0
        public async Task <Result <AuditDetailsModel> > Get(long id)
        {
            string userId = _httpContextAccessor.HttpContext.User.GetUserId();

            IBaseSpecification <AuditEntity, AuditDetailsModel> selectSpecification = SpecificationBuilder
                                                                                      .Create <AuditEntity>()
                                                                                      .Where(x => x.Id == id)
                                                                                      .WithUser(userId)
                                                                                      .Select(x => new AuditDetailsModel(
                                                                                                  x.Id,
                                                                                                  x.ActionType.GetDescription(),
                                                                                                  x.Created.ToString("o"),
                                                                                                  x.ResourceName,
                                                                                                  x.ObjectMetadata))
                                                                                      .Build();

            AuditDetailsModel auditDetailsModal = await _auditDAO.SingleOrDefault(selectSpecification);

            if (auditDetailsModal == null)
            {
                _logger.LogError($"No audit. AuditId {id}, UserId {userId}");
                return(Result.Fail <AuditDetailsModel>("no_audit", "No Audit"));
            }

            return(Result.Ok(auditDetailsModal));
        }
Пример #2
0
 public void AddNewAudit(AuditDetailsModel auditDetails)
 {
     try
     {
         var      database        = SingletonDb.Instance.GetDBConnection();
         object[] parameterValues = new object[] { auditDetails.ClientId, auditDetails.AccountTypeId, auditDetails.TurnoverTypeId, auditDetails.ProfRecNumber,
                                                   auditDetails.TuronOverMoney, auditDetails.AuditRequired, auditDetails.AuditStartDate, auditDetails.AuditEndDate, auditDetails.AuditBy, auditDetails.AuditFee };
         DbCommand cmd = database.GetStoredProcCommand("dbo.NewAudit_sp_Insert", parameterValues);
         database.ExecuteNonQuery(cmd);
     }
     catch (Exception ex)
     {
     }
 }
Пример #3
0
        public List <AuditDetailsModel> GetAllAuditRecords()
        {
            List <AuditDetailsModel> auditRecords = new List <AuditDetailsModel>();

            try
            {
                var       database        = SingletonDb.Instance.GetDBConnection();
                object[]  parameterValues = new object[] { };
                DbCommand cmd             = database.GetStoredProcCommand("dbo.NewAudit_sp_Select", parameterValues);

                using (IDataReader reader = database.ExecuteReader(cmd))
                {
                    while (reader.Read())
                    {
                        AuditDetailsModel auditRecord = new AuditDetailsModel();
                        auditRecord.AuditId        = reader.GetInt32(0);
                        auditRecord.ClientId       = !reader.IsDBNull(reader.GetOrdinal("in_ClientId")) ? reader.GetInt32(1) : 0;
                        auditRecord.AccountTypeId  = !reader.IsDBNull(reader.GetOrdinal("in_AccountTypeID")) ? reader.GetInt32(2) : 0;
                        auditRecord.TurnoverTypeId = !reader.IsDBNull(reader.GetOrdinal("in_TurnOverTypeId")) ? reader.GetInt32(3) : 0;
                        auditRecord.ProfRecNumber  = !reader.IsDBNull(reader.GetOrdinal("vc_ProfessionalReceipt")) ? reader.GetString(4) : string.Empty;
                        auditRecord.TuronOverMoney = !reader.IsDBNull(reader.GetOrdinal("in_TurnOver")) ? reader.GetInt32(5) : 0;
                        auditRecord.AuditRequired  = !reader.IsDBNull(reader.GetOrdinal("bt_AuditRequired")) ? reader.GetBoolean(6) : false;
                        auditRecord.AuditStartDate = !reader.IsDBNull(reader.GetOrdinal("dt_AuditStartDate")) ? reader.GetDateTime(7) : DateTime.Now;
                        auditRecord.AuditEndDate   = !reader.IsDBNull(reader.GetOrdinal("dt_AuditCompleteDate")) ? reader.GetDateTime(8) : DateTime.Now;
                        auditRecord.AuditBy        = !reader.IsDBNull(reader.GetOrdinal("in_AuditByID")) ? reader.GetInt32(9) : 0;
                        auditRecord.AuditFee       = !reader.IsDBNull(reader.GetOrdinal("in_AuditFee")) ? reader.GetInt32(10) : 0;
                        auditRecords.Add(auditRecord);
                    }
                }
            }
            catch (Exception ex)
            {
            }

            return(auditRecords);
        }
Пример #4
0
        public void AddNewAudit(AuditDetailsModel auditDetails)
        {
            AuditDetailsDal audit = new AuditDetailsDal();

            audit.AddNewAudit(auditDetails);
        }
Пример #5
0
        /// <summary>
        /// Method to return details of Audit History
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public IActionResult AuditDetails(long id)
        {
            AuditDetailsModel model = _service.GetById(id);

            List <AuditChange> rslt = new List <AuditChange>();

            AuditChange Change = new AuditChange
            {
                DateTimeStamp       = model.DateTime.Value.ToString("dd/MM/yyyy", CultureInfo.InvariantCulture),
                AuditActionTypeName = model.Action
            };

            var delta = JsonConvert.DeserializeObject <List <AuditDelta> >(model.Changes);

            foreach (AuditDelta objAuditDelta in delta)
            {
                if (objAuditDelta.FieldName == "ProductId")
                {
                    objAuditDelta.FieldName = "Product";

                    List <TblProduct> productList = SelectionList.ProductList();

                    if (!string.IsNullOrEmpty(objAuditDelta.ValueBefore))
                    {
                        objAuditDelta.ValueBefore = productList.FirstOrDefault(x => x.ProductId == Convert.ToInt16(objAuditDelta.ValueBefore)).FilmType;
                    }

                    if (!string.IsNullOrEmpty(objAuditDelta.ValueAfter))
                    {
                        objAuditDelta.ValueAfter = productList.FirstOrDefault(x => x.ProductId == Convert.ToInt16(objAuditDelta.ValueAfter)).FilmType;
                    }
                }

                if (objAuditDelta.FieldName == "ShiftId")
                {
                    objAuditDelta.FieldName = "Shift";

                    List <TblShiftType> productList = SelectionList.ShiftTypeList();

                    if (!string.IsNullOrEmpty(objAuditDelta.ValueBefore))
                    {
                        objAuditDelta.ValueBefore = productList.FirstOrDefault(x => x.ShiftId == Convert.ToInt16(objAuditDelta.ValueBefore)).Name;
                    }

                    if (!string.IsNullOrEmpty(objAuditDelta.ValueAfter))
                    {
                        objAuditDelta.ValueAfter = productList.FirstOrDefault(x => x.ShiftId == Convert.ToInt16(objAuditDelta.ValueAfter)).Name;
                    }
                }

                if (objAuditDelta.FieldName == "ShiftInchargeId")
                {
                    objAuditDelta.FieldName = "Shift Incharge";

                    List <TblUser> productList = SelectionList.UserList();

                    if (!string.IsNullOrEmpty(objAuditDelta.ValueBefore))
                    {
                        objAuditDelta.ValueBefore = productList.FirstOrDefault(x => x.UserId == Convert.ToInt16(objAuditDelta.ValueBefore)).Name;
                    }

                    if (!string.IsNullOrEmpty(objAuditDelta.ValueAfter))
                    {
                        objAuditDelta.ValueAfter = productList.FirstOrDefault(x => x.UserId == Convert.ToInt16(objAuditDelta.ValueAfter)).Name;
                    }
                }

                if (objAuditDelta.FieldName == "StatusId")
                {
                    objAuditDelta.FieldName = "Status";

                    List <TblJumboStatus> productList = SelectionList.JumboStatusList();

                    if (!string.IsNullOrEmpty(objAuditDelta.ValueBefore))
                    {
                        objAuditDelta.ValueBefore = productList.FirstOrDefault(x => x.StatusId == Convert.ToInt16(objAuditDelta.ValueBefore)).Name;
                    }

                    if (!string.IsNullOrEmpty(objAuditDelta.ValueAfter))
                    {
                        objAuditDelta.ValueAfter = productList.FirstOrDefault(x => x.StatusId == Convert.ToInt16(objAuditDelta.ValueAfter)).Name;
                    }
                }


                if (objAuditDelta.FieldName == "BuyerId")
                {
                    objAuditDelta.FieldName = "Buyer";

                    List <TblCustomer> productList = SelectionList.CustomerList();

                    if (!string.IsNullOrEmpty(objAuditDelta.ValueBefore))
                    {
                        objAuditDelta.ValueBefore = productList.FirstOrDefault(x => x.CustomerId == Convert.ToInt16(objAuditDelta.ValueBefore)).Name;
                    }

                    if (!string.IsNullOrEmpty(objAuditDelta.ValueAfter))
                    {
                        objAuditDelta.ValueAfter = productList.FirstOrDefault(x => x.CustomerId == Convert.ToInt16(objAuditDelta.ValueAfter)).Name;
                    }
                }

                if (objAuditDelta.FieldName == "ConsigneeId")
                {
                    objAuditDelta.FieldName = "Shift";

                    List <TblConsignee> productList = SelectionList.ConsigneeList();

                    if (!string.IsNullOrEmpty(objAuditDelta.ValueBefore))
                    {
                        objAuditDelta.ValueBefore = productList.FirstOrDefault(x => x.ConsigneeId == Convert.ToInt16(objAuditDelta.ValueBefore)).Name;
                    }

                    if (!string.IsNullOrEmpty(objAuditDelta.ValueAfter))
                    {
                        objAuditDelta.ValueAfter = productList.FirstOrDefault(x => x.ConsigneeId == Convert.ToInt16(objAuditDelta.ValueAfter)).Name;
                    }
                }


                if (objAuditDelta.FieldName == "CoreId")
                {
                    objAuditDelta.FieldName = "Core";

                    List <TblCore> productList = SelectionList.CoreList();

                    if (!string.IsNullOrEmpty(objAuditDelta.ValueBefore))
                    {
                        objAuditDelta.ValueBefore = productList.FirstOrDefault(x => x.CoreId == Convert.ToInt16(objAuditDelta.ValueBefore)).Name + " " +
                                                    productList.FirstOrDefault(x => x.CoreId == Convert.ToInt16(objAuditDelta.ValueBefore)).Thickness;
                    }

                    if (!string.IsNullOrEmpty(objAuditDelta.ValueAfter))
                    {
                        objAuditDelta.ValueAfter = productList.FirstOrDefault(x => x.CoreId == Convert.ToInt16(objAuditDelta.ValueAfter)).Name + " " +
                                                   productList.FirstOrDefault(x => x.CoreId == Convert.ToInt16(objAuditDelta.ValueAfter)).Thickness;
                    }
                }

                if (objAuditDelta.FieldName == "TreatmentId")
                {
                    objAuditDelta.FieldName = "Treatment";

                    List <TblTreatment> productList = SelectionList.SlittingTreatmentList();

                    if (!string.IsNullOrEmpty(objAuditDelta.ValueBefore))
                    {
                        objAuditDelta.ValueBefore = productList.FirstOrDefault(x => x.TreatmentId == Convert.ToInt16(objAuditDelta.ValueBefore)).Name;
                    }

                    if (!string.IsNullOrEmpty(objAuditDelta.ValueAfter))
                    {
                        objAuditDelta.ValueAfter = productList.FirstOrDefault(x => x.TreatmentId == Convert.ToInt16(objAuditDelta.ValueAfter)).Name;
                    }
                }

                if (objAuditDelta.FieldName == "JumboId")
                {
                    objAuditDelta.FieldName = "Jumbo Nr";

                    List <TblJumbo> productList = SelectionList.JumboList();

                    if (!string.IsNullOrEmpty(objAuditDelta.ValueBefore))
                    {
                        objAuditDelta.ValueBefore = productList.FirstOrDefault(x => x.JumboId == Convert.ToInt16(objAuditDelta.ValueBefore)).JumboNo;
                    }

                    if (!string.IsNullOrEmpty(objAuditDelta.ValueAfter))
                    {
                        objAuditDelta.ValueAfter = productList.FirstOrDefault(x => x.JumboId == Convert.ToInt16(objAuditDelta.ValueAfter)).JumboNo;
                    }
                }

                if (objAuditDelta.FieldName == "OrderId")
                {
                    objAuditDelta.FieldName = "Order Nr";

                    List <TblOrder> productList = SelectionList.OrderList();

                    if (!string.IsNullOrEmpty(objAuditDelta.ValueBefore))
                    {
                        objAuditDelta.ValueBefore = productList.FirstOrDefault(x => x.OrderId == Convert.ToInt16(objAuditDelta.ValueBefore)).OrderNo;
                    }

                    if (!string.IsNullOrEmpty(objAuditDelta.ValueAfter))
                    {
                        objAuditDelta.ValueAfter = productList.FirstOrDefault(x => x.OrderId == Convert.ToInt16(objAuditDelta.ValueAfter)).OrderNo;
                    }
                }
            }

            Change.Changes.AddRange(delta);
            rslt.Add(Change);

            return(PartialView("_Details", rslt));
        }