public CustomerViewModel AddCustomer(CustomerViewModel entity) { var data = new tbl_Customer { CustomerId = entity.customerId, FirstName = entity.firstName, LastName = entity.lastName, OtherName = entity.otherName, PhoneNo = entity.phoneNo, Address = entity.address, Email = entity.email, AlternativeEmail = entity.alternativeEmail, AlternativePhoneNo = entity.alternativePhoneNo, LoyaltyCardNumber = entity.loyaltyCardNumber, IsActive = entity.isActive, CreatedOn = DateTime.Now, CreatedBy = "admin", ModifiedOn = DateTime.Now, ModifiedBy = "admin" }; context.tbl_Customer.Add(data); context.SaveChanges(); return(entity); }
public VendorPaymentViewModel AddVendorPayment(VendorPaymentViewModel entity) { var data = new tbl_VendorPayment { VendorPaymentId = entity.vendorPaymentId, VendorId = entity.vendorId, PurchaseOrderId = entity.purchaseOrderId, PurchaseOrderDetailId = entity.purchaseOrderDetailId, InvoiceNo = entity.invoiceNo, InvoiceTotalCost = entity.invoiceTotalCost, AmountAlreadyPaid = entity.amountAlreadyPaid, AmountToPay = entity.amountToPay, Balance = entity.balance, PaymentModeId = entity.paymentModeId, PaymentDate = entity.paymentDate, CreatedBy = "admin", CreatedOn = entity.createdOn, ModifiedBy = "admin", ModifiedOn = entity.modifiedOn }; context.tbl_VendorPayment.Add(data); context.SaveChanges(); return(entity); }
public BranchViewModel AddBranch(BranchViewModel entity) { var data = new tbl_Branch { BranchId = entity.branchId, BranchName = entity.branchName, StateId = entity.stateId, CountryId = entity.countryId, BranchAddress = entity.branchAddress, ContactPerson = entity.contactPerson, PhoneNo = entity.phoneNo, Email = entity.email, IsStore = entity.isStore, IsWarehouse = entity.isWarehouse, IsActive = entity.isActive, CreatedOn = DateTime.Now, CreatedBy = "admin", ModifiedOn = DateTime.Now, ModifiedBy = "admin" }; context.tbl_Branch.Add(data); context.SaveChanges(); return(entity); }
public bool SaleProduct(List <SalesDetailsViewModel> orders) { var result = false; foreach (var item in orders) { var existingStock = context.tbl_Stock.Where(s => s.ProductId == item.productId).FirstOrDefault(); if (existingStock != null) { existingStock.QuantitySupplied -= item.quantity; } if (context.SaveChanges() > 0) { AddSalesDetails(item); var stockCard = new StockCardViewModel { dateRecieved = existingStock.DeliveryDate, quantityRecieved = existingStock.QuantitySupplied, //quantityRemaining = existingStock.QuantitySupplied - existingStock.QuantitySold, stockId = existingStock.StockId, createdOn = existingStock.CreatedOn, createdBy = existingStock.CreatedBy, lastDateUpdated = DateTime.Now }; card.AddStockCarda(stockCard); result = true; } else { return(false); } } return(result); }
public StaffViewModel AddStaff(StaffViewModel entity) { var data = new tbl_Staff { StaffId = entity.staffId, FirstName = entity.firstName, LastName = entity.lastName, OtherName = entity.otherName, PhoneNo = entity.phoneNo, AlternativePhoneNo = entity.alternativePhoneNo, Address = entity.address, Email = entity.email, AlternativeEmail = entity.alternativeEmail, Designation = entity.designation, IsActive = entity.isActive, CreatedOn = DateTime.Now, CreatedBy = "admin", ModifiedBy = "admin", ModifiedOn = DateTime.Now }; context.tbl_Staff.Add(data); context.SaveChanges(); return(entity); }
public TransactionStatusViewModel AddTransactionStatus(TransactionStatusViewModel entity) { var data = new tbl_TransactionStatus { TransactionStatusId = entity.transactionStatusId, TransactionStatus = entity.transactionStatus }; context.tbl_TransactionStatus.Add(data); context.SaveChanges(); return(entity); }
public SalesTypeViewModel AddSalesType(SalesTypeViewModel entity) { var data = new tbl_SalesType { SalesTypeId = entity.salesTypeId, SalesType = entity.salesType }; context.tbl_SalesType.Add(data); context.SaveChanges(); return(entity); }
public MeasurementViewModel AddMeasurement(MeasurementViewModel entity) { var data = new tbl_Measurement { UnitOfMeasurementId = entity.unitOfMeasurementId, UOM = entity.uom, IsActive = entity.isActive }; context.tbl_Measurement.Add(data); context.SaveChanges(); return(entity); }
public bool UpdateStock(StockViewModel entity) { var data = (from d in context.tbl_Stock where d.StockId == entity.stockId select d).SingleOrDefault(); if (data != null) { data.StockId = entity.stockId; data.ProductId = entity.productId; data.PurchaseOrderDetailId = entity.purchaseOrderDetailId; data.StockCode = entity.stockCode; data.PurchaseOrderId = entity.purchaseOrderId; data.QuantitySold = entity.quantitySold; data.QuantitySupplied = entity.quantitySupplied; data.SupplyDate = DateTime.Now; data.CostPerItem = entity.costPerItem; data.SellingPrice = entity.sellingPrice; data.BranchId = entity.branchId; data.DeliveryDate = DateTime.Now; data.IsActive = entity.isActive; data.IsSoldOut = entity.isSoldOut; data.ModifiedOn = DateTime.Now; data.ModifiedBy = "admin"; } ; return(context.SaveChanges() > 0); }
public StockCardViewModel AddStockCard(StockCardViewModel entity) { var data = new tbl_StockCard { StockId = entity.stockId, QuantityRecieved = entity.quantityRecieved, QuantitySold = entity.quantitySold, DateRecieved = entity.dateRecieved, LastDateUpdated = entity.lastDateUpdated, CreatedOn = entity.createdOn, CreatedBy = entity.createdBy }; context.tbl_StockCard.Add(data); context.SaveChanges(); return(entity); }
public BrandViewModel AddBrand(BrandViewModel entity) { var data = new tbl_Brand() { BrandId = entity.brandId, BrandName = entity.brandName, IsActive = entity.isActive, CreatedOn = entity.createdOn, CreatedBy = entity.createdBy, ModifiedOn = entity.modifiedOn, ModifiedBy = entity.modifiedBy }; context.tbl_Brand.Add(data); context.SaveChanges(); return(entity); }
public SectionViewModel AddSection(SectionViewModel entity) { var data = new tbl_Section { SectionId = entity.sectionId, Section = entity.section, IsActive = entity.isActive, CreatedOn = DateTime.Now, CreatedBy = "admin", ModifiedOn = DateTime.Now, ModifiedBy = "admin" }; context.tbl_Section.Add(data); context.SaveChanges(); return(entity); }
public StateViewModel AddState(StateViewModel entity) { var data = new tbl_State { StateId = entity.stateId, StateName = entity.stateName, IsActive = entity.isActive, CreatedBy = "admin", CreatedOn = DateTime.Now, ModifiedOn = DateTime.Now, ModifiedBy = "admin" }; context.tbl_State.Add(data); context.SaveChanges(); return(entity); }
public CategoryViewModel AddCategory(CategoryViewModel entity) { var data = new tbl_Category { //CategoryId = entity.categoryId, CategoryName = entity.categoryName, IsActive = entity.isActive, CreatedBy = "admin", CreatedOn = DateTime.Now, ModifiedBy = "admin", ModifiedOn = DateTime.Now }; context.tbl_Category.Add(data); context.SaveChanges(); return(entity); }
public PaymentModeViewModel AddPaymentMode(PaymentModeViewModel entity) { var data = new tbl_PaymentMode { PaymentModeId = entity.paymentModeId, PaymentMode = entity.paymentMode, IsActive = entity.isActive, RequiredReferenceNo = entity.requiredReferenceNo, CreatedOn = DateTime.Now, CreatedBy = "admin", ModifiedOn = DateTime.Now, ModifiedBy = "admin" }; context.tbl_PaymentMode.Add(data); context.SaveChanges(); return(entity); }
public VendorViewModel AddVendor(VendorViewModel entity) { var data = new tbl_Vendor { VendorId = entity.vendorId, Vendor = entity.vendor, Address = entity.address, PhoneNo = entity.phoneNo, CreatedBy = "admin", CreatedOn = DateTime.Now, ModifiedBy = "admin", ModifiedOn = DateTime.Now, IsActive = entity.isActive }; context.tbl_Vendor.Add(data); context.SaveChanges(); return(entity); }
public DamagesViewModel AddDamages(DamagesViewModel entity) { var data = new tbl_Damages { DamagesId = entity.damagesId, ProductId = entity.productId, QuantityDamaged = entity.quantityDamaged, DamagedDate = DateTime.Now, Reason = entity.reason, StockId = entity.stockId, CreatedBy = "admin", CreatedOn = DateTime.Now, ModifiedBy = "admin", ModifiedOn = DateTime.Now }; context.tbl_Damages.Add(data); context.SaveChanges(); return(entity); }
public BanksViewModel AddBank(BanksViewModel entity) { var data = new tbl_Banks { BankId = entity.bankId, BankName = entity.bankName, IsActive = entity.isActive, }; context.tbl_Banks.Add(data); context.SaveChanges(); return(entity); //if (context.SaveChanges() > 0) //{ // return entity; //} //else //{ // return null; //} }
public PaymentViewModel AddPayment(PaymentViewModel entity) { var data = new tbl_Payment { PaymentId = entity.paymentId, ActualAmount = entity.actualAmount, BatchNo = entity.batchNo, PaymentModeId = entity.paymentModeId, PaymentDate = DateTime.Now, RecievedAmount = entity.recievedAmount, SalesTypeId = entity.salesTypeId, TransactionStatusId = entity.transactionStatusId, CreatedOn = DateTime.Now, CreatedBy = "admin", ModifiedOn = DateTime.Now, ModifiedBy = "admin" }; context.tbl_Payment.Add(data); context.SaveChanges(); return(entity); }
public CompanyViewModel AddCompany(CompanyViewModel company) { var data = new tbl_Company { CompanyId = company.companyId, CompanyName = company.companyName, CompanyAddress = company.companyAddress, PhoneNo = company.phoneNo, Email = company.email, Website = company.website, CompanyLogo = company.companyLogo, IsActive = company.isActive, CreatedBy = "admin", CreatedOn = DateTime.Now, ModifiedBy = "admin", ModifiedOn = DateTime.Now }; context.tbl_Company.Add(data); context.SaveChanges(); return(company); }
public string ConfirmReferenceNo(int referenceType, int companyId) { tbl_ReferenceManager data = null; if (maxNo == 0) { var lastCount = context.tbl_ReferenceManager. Where(c => c.CompanyId == companyId && c.ReferenceType == referenceType).ToList(); maxNo = lastCount.Count == 0 ? 0: lastCount.Max(c => c.SeriaNo); ++maxNo; } else { maxNo++; } var reference = context.tbl_ReferenceManager .Where(c => c.SeriaNo == maxNo && c.ReferenceType == referenceType); if (reference.Any()) { ConfirmReferenceNo(referenceType, companyId); } else { data = new tbl_ReferenceManager { ReferenceNo = maxNo.ToString().PadZeros(), ReferenceType = referenceType, SeriaNo = maxNo, ValidReference = true, CreatedOn = DateTime.Now, CompanyId = companyId }; context.tbl_ReferenceManager.Add(data); context.SaveChanges(); } return(data.ReferenceNo); }
public bool ReceiveAllOrders(List <OrderDetailViewModel> orders) { bool result = false; foreach (var item in orders) { var order = context.tbl_PurchaseOrderDetail .Where(c => c.PurchaseOrderDetailId == item.purchaseOrderDetailId) .FirstOrDefault(); order.IsRecieved = true; StockViewModel stork = AddStockItems(item, order); stock.AddStockEntries(stork); //var existingStock = context.tbl_Stock.Where(s => s.ProductId == item.productId).FirstOrDefault(); //if (existingStock != null) //{ // existingStock.QuantitySupplied += item.quantity; //} //else //{ // StockViewModel stork = AddStockItems(item, order); // stock.AddStockEntries(stork); //} if (context.SaveChanges() > 0) { UpdateOrderifFullyReceived(item.purchaseOrderId); result = true; } else { return(false); } } return(result); }