public int InsertAllottedQuantity(AllotedQuantityDTO allottedQty) { allotedquantity allottedQuantityEntity = new allotedquantity(); AutoMapper.Mapper.Map(allottedQty, allottedQuantityEntity); ESalesUnityContainer.Container.Resolve<IGenericRepository<allotedquantity>>().Save(allottedQuantityEntity); return allottedQuantityEntity.Alloted_Id; }
/// <summary> /// Updates the lifting interval by business type id. /// </summary> /// <param name="businessTypeId">The business type id.</param> /// <param name="annualLimit">The annual limit.</param> /// <param name="liftingLimit">The lifting limit.</param> /// <param name="liftingInterval">The lifting interval.</param> /// <param name="truckRegId">The truck reg id.</param> private void UpdateLiftingIntervalByBusinessTypeId(int businessTypeId, int annualLimit, int liftingLimit, int liftingInterval, int truckRegId) { List<CustomerMaterialMapDTO> lstCustomerMatDetails = new List<CustomerMaterialMapDTO>(); List<CustomerMaterialMapDTO> lstCustomerMat = new List<CustomerMaterialMapDTO>(); List<AllotedQuantityDTO> lstQty = new List<AllotedQuantityDTO>(); int quantityFlag = 0; int qtyId = 0; // Update truckregtypeid for business other than bricks if (businessTypeId != 1) { ESalesUnityContainer.Container.Resolve<ILiftingLimit>().UpdateLiftingLimitTruckRegId(truckRegId); } // Get details of customer by businesstypeid List<int> lstCustomer = ESalesUnityContainer.Container.Resolve<ICustomerService>().GetCustomerIdByBusinessTypeId(businessTypeId); // Get all customermaterialmap details lstCustomerMatDetails = ESalesUnityContainer.Container.Resolve<ICustomerMaterialService>().GetCustomerMaterialDetailsList(); // Get allotted quantity details lstQty = ESalesUnityContainer.Container.Resolve<ILiftingLimit>().GetAllottedQuantityDetails(); // Check if quantity exists in allotted quantity details foreach (AllotedQuantityDTO item in lstQty) { if (item.Alloted_Quantity == annualLimit.ToString()) { quantityFlag = 1; qtyId = item.Alloted_Id; break; } } // Will add new entry in allotted quantity if it doesn't exist if (quantityFlag != 1) { AllotedQuantityDTO allottedQty = new AllotedQuantityDTO(); allottedQty.Alloted_Quantity = annualLimit.ToString(); allottedQty.Alloted_CreatedBy = GetCurrentUserId(); allottedQty.Alloted_CreatedDate = DateTime.Now; allottedQty.Alloted_IsDeleted = false; qtyId = ESalesUnityContainer.Container.Resolve<ILiftingLimit>().InsertAllottedQuantity(allottedQty); } // Get filtered list of customers based on businesstypeid lstCustomerMat = lstCustomerMatDetails.FindAll(C => lstCustomer.Contains(C.Cust_Mat_CustId)); foreach (CustomerMaterialMapDTO item in lstCustomerMat) { customermaterialmap upCustomerMatEntity = new customermaterialmap(); item.Cust_Mat_LiftingLimit = liftingLimit; item.Cust_Mat_AllotedQuantityId = qtyId; item.Cust_Mat_Timeinterval = liftingInterval; item.Cust_Mat_LastUpdatedDate = DateTime.Now; AutoMapper.Mapper.Map(item, upCustomerMatEntity); ESalesUnityContainer.Container.Resolve<IGenericRepository<customermaterialmap>>().Update(upCustomerMatEntity); } }