public static List <PurchaseOrderViewModel> GetDataBySearch(string searchKey) { List <PurchaseOrderViewModel> result = new List <PurchaseOrderViewModel>(); using (POSContext context = new POSContext()) { result = (from op in context.TPurchaseOrder join sp in context.TSuppliers on op.SupplierID equals sp.ID join ops in context.TPurchaseOrderStatus on op.StatusID equals ops.ID where op.OrderNo.Contains(searchKey) || sp.Name.Contains(searchKey) || op.Total.ToString().Contains(searchKey) select new PurchaseOrderViewModel() { ID = op.ID, StatusID = op.StatusID, StatusName = ops.StatusName, OrderNo = op.OrderNo, Supplier = sp.Name, Total = op.Total, CreatedBy = op.CreatedBy, CreatedOn = op.CreatedOn, ModifiedBy = op.ModifiedBy, ModifiedOn = op.ModifiedOn }).ToList(); } return(result); }
public POSController(IPOSItemValidator validator, ITransactionRequestValidator cartValidator, POSContext context, TransactionContext cart) { this._context = context; this._validator = validator; this._cartValidator = cartValidator; this.cart = cart; this._user = POSController.CreateUser(); if (!this._context.Users.Any(u => u.user_id == this._user.user_id)) { this._user = POSController.CreateUser(); this._context.Users.Add(this._user); this._context.SaveChanges(); } else { var users = this._context.Users.Include(u => u.rights); foreach (var user in users) { if (user.user_id == this._user.user_id) { this._user = user; } } } }
public static string OrderNo() { string OrderNo; int index = 1; OrderNo = "#" + string.Format("{0:00}", DateTime.Now.Month) + string.Format("{0:00}", DateTime.Now.Day); using (POSContext context = new POSContext()) { var result = context.TPurchaseOrder .Where(m => m.OrderNo.Contains(OrderNo)) .OrderByDescending(x => x.OrderNo) .FirstOrDefault(); if (result == null) { OrderNo = OrderNo + string.Format("{0:00000}", index); } else { string[] OrNo = result.OrderNo.Split('#'); index = int.Parse(OrNo[1]) + 1; OrderNo = "#" + index.ToString(); } } return(OrderNo); }
public static List <PurchaseOrderViewModel> GetDataByStatus(int id) { List <PurchaseOrderViewModel> result = new List <PurchaseOrderViewModel>(); using (POSContext context = new POSContext()) { //result = context.TPurchaseOrder.ToList(); result = (from op in context.TPurchaseOrder join sp in context.TSuppliers on op.SupplierID equals sp.ID join ops in context.TPurchaseOrderStatus on op.StatusID equals ops.ID where ops.ID == id select new PurchaseOrderViewModel() { ID = op.ID, StatusID = op.StatusID, StatusName = ops.StatusName, OrderNo = op.OrderNo, Supplier = sp.Name, Total = op.Total, CreatedBy = op.CreatedBy, CreatedOn = op.CreatedOn, ModifiedBy = op.ModifiedBy, ModifiedOn = op.ModifiedOn }).ToList(); } return(result); }
public static List <SuppliersViewModel> GetSearch(string searchkey) { List <SuppliersViewModel> result = new List <SuppliersViewModel>(); using (POSContext context = new POSContext()) { result = (from s in context.TSuppliers join d in context.TDistrict on s.DistrictID equals d.ID into dTmp from d in dTmp.DefaultIfEmpty() join r in context.TRegion on s.RegionID equals r.ID into rTmp from r in rTmp.DefaultIfEmpty() join p in context.TProvince on s.ProvinceID equals p.ID into pTmp from p in pTmp.DefaultIfEmpty() where s.Name.Contains(searchkey) || d.DistrictName.Contains(searchkey) || p.ProvinceName.Contains(searchkey) || s.Phone.Contains(searchkey) select new SuppliersViewModel() { ID = s.ID, Name = s.Name, Address = s.Address, DistrictID = s.DistrictID, DistrictName = d.DistrictName, RegionID = s.RegionID, RegionName = r.RegionName, ProvinceID = s.ProvinceID, ProvinceName = p.ProvinceName, AddressFull = s.Address + "," + d.DistrictName + "," + r.RegionName + "," + p.ProvinceName + "," + s.PostalCode, Email = s.Email, Phone = s.Phone, } ).OrderByDescending(x => x.Name).ToList(); } return(result); }
public static List <PurchaseOrderViewModel> GetDataByOutlet(int outletid) { List <PurchaseOrderViewModel> result = new List <PurchaseOrderViewModel>(); using (POSContext context = new POSContext()) { //result = context.TPurchaseOrder.ToList(); result = (from op in context.TPurchaseOrder join sp in context.TSuppliers on op.SupplierID equals sp.ID join oph in context.TPurchaseOrderHistory on op.ID equals oph.HeaderID join ops in context.TPurchaseOrderStatus on oph.StatusID equals ops.ID join opd in context.TPurchaseOrderDetail on op.ID equals opd.HeaderID join ot in context.TOutlet on op.OutletID equals ot.ID where op.OutletID == outletid select new PurchaseOrderViewModel() { ID = oph.ID, OutletID = op.OutletID, OutletName = ot.OutletName, StatusID = oph.StatusID, SupplierID = op.SupplierID, StatusName = ops.StatusName, OrderNo = op.OrderNo, Notes = op.Notes, Supplier = sp.Name, SubTotal = opd.SubTotal, CreatedBy = op.CreatedBy, CreatedOn = op.CreatedOn, ModifiedBy = op.ModifiedBy, ModifiedOn = op.ModifiedOn }).ToList(); } return(result); }
public static SuppliersViewModel GetDataByID(int id) { SuppliersViewModel result = new SuppliersViewModel(); using (POSContext context = new POSContext()) { result = (from po in context.TPurchaseOrder join a in context.TSuppliers on po.SupplierID equals a.ID join p in context.TProvince on a.ProvinceID equals p.ID join r in context.TRegion on a.RegionID equals r.ID join d in context.TDistrict on a.DistrictID equals d.ID select new SuppliersViewModel() { ID = a.ID, Address = a.Address, DistrictID = a.DistrictID, DistrictName = d.DistrictName, RegionID = a.RegionID, RegionName = r.RegionName, Email = a.Email, ProvinceID = a.ProvinceID, ProvinceName = p.ProvinceName, Name = a.Name, Phone = a.Phone, PostalCode = a.PostalCode, CreatedBy = a.CreatedBy, CreatedOn = a.CreatedOn, ModifiedBy = a.ModifiedBy, ModifiedOn = a.ModifiedOn }).FirstOrDefault(); } return(result); }
public static List <SuppliersViewModel> GetData() { // proses instansiasi untuk mendefinisikan list baru List <SuppliersViewModel> result = new List <SuppliersViewModel>(); // selanjutnya adalah proses untuk membuat linq using (POSContext context = new POSContext()) { result = (from s in context.TSuppliers join d in context.TDistrict on s.DistrictID equals d.ID into dTmp from d in dTmp.DefaultIfEmpty() join r in context.TRegion on s.RegionID equals r.ID into rTmp from r in rTmp.DefaultIfEmpty() join p in context.TProvince on s.ProvinceID equals p.ID into pTmp from p in pTmp.DefaultIfEmpty() select new SuppliersViewModel() { ID = s.ID, Name = s.Name, Address = s.Address, DistrictID = s.DistrictID, DistrictName = d.DistrictName, RegionID = s.RegionID, RegionName = r.RegionName, ProvinceID = s.ProvinceID, ProvinceName = p.ProvinceName, AddressFull = s.Address + "," + d.DistrictName + "," + r.RegionName + "," + p.ProvinceName + "," + s.PostalCode, Email = s.Email, Phone = s.Phone, } ).OrderByDescending(x => x.Name).ToList(); } return(result); }
public ActionResult Create(ViewModel model) { //if (ModelState.IsValid) //{ // using (var context = new POSContext()) // { // var address = from c in context.Addresses // where c.Id == model.AddressId // select c; // var customer = new Customer(model.Customer.LastName, model.Customer.FirstName, (Address)address, model.Customer.EmailAddress); // context.Customers.Add(customer); // context.SaveChanges(); // return RedirectToAction("Index"); // } //} using (var context = new POSContext()) { var id = Convert.ToInt32(model.AddressId); var q = from c in context.Addresses where c.Id == id select c; var customer = new Customer(model.Customer.LastName, model.Customer.FirstName, (Address)q.First(), model.Customer.EmailAddress); context.Customers.Add(customer); context.SaveChanges(); return(RedirectToAction("Index")); } }
public static List <ItemsVariantViewModel> GetData() { List <ItemsVariantViewModel> result = new List <ItemsVariantViewModel>(); using (POSContext context = new POSContext()) { result = (from iv in context.TItemsVariant join ii in context.TItemsIventory on iv.ID equals ii.VariantID into iiTmp from ii in iiTmp.DefaultIfEmpty() join i in context.TItems on iv.ItemID equals i.ID into iTmp from i in iTmp.DefaultIfEmpty() join asd in context.TAdjusmentStockDetail on iv.ID equals asd.VariantID into asdTmp from asd in asdTmp.DefaultIfEmpty() join a in context.TAdjusmentStock on asd.HeaderID equals a.ID into aTmp from a in aTmp.DefaultIfEmpty() select new ItemsVariantViewModel() { ID = iv.ID, ItemID = iv.ItemID, VariantName = iv.VariantName, Price = iv.Price, SKU = iv.SKU, CreatedOn = iv.CreatedOn, Note = a.Note //ditambah serta ditukar dari data ana }).ToList(); } return(result); }
public static List <CustomersViewModel> GetData() { List <CustomersViewModel> result = new List <CustomersViewModel>(); using (POSContext context = new POSContext()) { result = (from x in context.TCustomers select new CustomersViewModel() { ID = x.ID, CustomerName = x.CustomerName, Phone = x.Phone, Email = x.Email, ProvinceID = x.ProvinceID, RegionID = x.RegionID, DistrictID = x.DistrictID, Address = x.Address, CreatedBy = x.CreatedBy, CreatedOn = x.CreatedOn, ModifiedBy = x.ModifiedBy, ModifiedOn = x.ModifiedOn, BirthDate = x.BirthDate, }).ToList(); } return(result); }
public static List <ItemsIventoryViewModel> GetDataBySearch(string searchKey) { List <ItemsIventoryViewModel> result = new List <ItemsIventoryViewModel>(); using (POSContext context = new POSContext()) { result = (from ii in context.TItemsIventory join iv in context.TItemsVariant on ii.VariantID equals iv.ID where iv.VariantName.Contains(searchKey) select new ItemsIventoryViewModel() { ID = ii.ID, Adjusment = ii.Adjusment, AlertAt = ii.AlertAt, Beginning = ii.Beginning, PurchaseOrder = ii.PurchaseOrder, VariantID = ii.VariantID, VariantName = iv.VariantName, Transfer = ii.Transfer, Ending = ii.Ending, Sales = ii.Sales, ModifiedBy = ii.ModifiedBy, ModifiedOn = ii.ModifiedOn, CreatedBy = ii.CreatedBy, CreatedOn = ii.CreatedOn }).ToList(); } return(result); }
public ActionResult Delete(CategoriesViewModel model) { if (ModelState.IsValid) { using (POSContext context = new POSContext()) { bool isSave = false; var VOutlet = context.TOutlet.ToList(); foreach (var item in VOutlet) { Categories Kategori = context.TCategories.Where(m => m.Name == model.Name).FirstOrDefault(); context.TCategories.Remove(Kategori); try { context.SaveChanges(); isSave = true; } catch (Exception) { isSave = false; } } if (isSave == true) { return(RedirectToAction("Index")); } } } return(PartialView("Delete", model)); }
public static List <Outlet> GetDataByUser(int userId) { List <Outlet> result = new List <Outlet>(); using (POSContext context = new POSContext()) { result = (from a in context.TOutlet join b in context.TEmployeeOutlet on a.ID equals b.OutletID join c in context.TEmployee on b.EmployeeID equals c.ID join d in context.TUser on c.Email equals d.Email where d.Id == userId select new Outlet() { ID = a.ID, Address = a.Address, RegionID = a.RegionID, ProvinceID = a.ProvinceID, PostalCode = a.PostalCode, Phone = a.Phone, OutletName = a.OutletName, Email = a.Email, DistrictID = a.DistrictID, CreatedBy = a.CreatedBy, CreatedOn = a.CreatedOn, ModifiedBy = a.ModifiedBy, ModifiedOn = a.ModifiedOn }).ToList(); } return(result); }
// ListItems yang akan diambil ini disesuaikan dengan kategori ID public ActionResult UpdateItems(CategoriesViewModel models) { using (POSContext context = new POSContext()) { int i = 0; //var userId = User.Identity.GetUserId<int>(); //int OutletId = 0; foreach (var item in models.ItemID) { Items data = context.TItems.Where(x => x.ID == item).FirstOrDefault(); if (data != null) { data.CategoryID = models.ID; } i++; } try { context.SaveChanges(); return(RedirectToAction("Index"));; } catch (Exception) { throw; }; } }
public static List <TransferViewModel> GetData() //getdata dari transferstock model { List <TransferViewModel> result = new List <TransferViewModel>(); using (POSContext context = new POSContext()) { result = (from ts in context.TTransferStock join tsd in context.TTransferStockDetail on ts.ID equals tsd.HeaderID join iv in context.TItemsVariant on tsd.VariantID equals iv.ID join ii in context.TItemsIventory on tsd.ID equals ii.VariantID select new TransferViewModel() { ID = ts.ID, ToOutlet = ts.ToOutlet, Note = ts.Note, HeaderID = ts.ID, //InStock = ii.Beginning, //Quantity = ii.Transfer, VariantName = iv.VariantName, //SKU = iv.SKU, }).ToList(); } return(result); }
public static List <ItemIventoryViewModel> GetDataSum() { List <ItemIventoryViewModel> result = new List <ItemIventoryViewModel>(); using (POSContext context = new POSContext()) { result = (from ii in context.TItemsIventory join iv in context.TItemsVariant on ii.VariantID equals iv.ID join i in context.TItems on iv.ItemID equals i.ID join c in context.TCategories on i.CategoryID equals c.ID select new ItemIventoryViewModel() { ID = ii.ID, Adjusment = ii.Adjusment, AlertAt = ii.AlertAt, Beginning = ii.Beginning, PurchaseOrder = ii.PurchaseOrder, VariantID = ii.VariantID, VariantName = iv.VariantName, Transfer = ii.Transfer, Ending = ii.Ending, Sales = ii.Sales, ModifiedBy = ii.ModifiedBy, ModifiedOn = ii.ModifiedOn, CreatedBy = ii.CreatedBy, CreatedOn = ii.CreatedOn, ItemVarName = i.Name + " - " + iv.VariantName, Name = c.Name }).ToList(); } return(result); }
public static List <PurchaseOrderDetailsViewModel> GetData() { List <PurchaseOrderDetailsViewModel> result = new List <PurchaseOrderDetailsViewModel>(); using (POSContext context = new POSContext()) { result = (from pod in context.TPurchaseOrderDetail join ii in context.TItemsIventory on pod.VariantID equals ii.VariantID join iv in context.TItemsVariant on pod.VariantID equals iv.ID select new PurchaseOrderDetailsViewModel { ID = pod.ID, VariantID = pod.VariantID, VarianName = iv.VariantName, InStok = ii.Ending, Quantity = pod.Quantity, HeaderID = pod.HeaderID, UnitCost = pod.UnitCost, SubTotal = pod.SubTotal, CreatedBy = pod.CreatedBy, CreatedOn = pod.CreatedOn, ModifiedBy = pod.ModifiedBy, ModifiedOn = pod.ModifiedOn }).ToList(); } return(result); }
public static List <CustomersViewModel> GetDataSearch(string searchKey) { List <CustomersViewModel> result = new List <CustomersViewModel>(); using (POSContext context = new POSContext()) { result = (from x in context.TCustomers where x.CustomerName.Contains(searchKey) || x.Email.Contains(searchKey) || x.Phone.Contains(searchKey) select new CustomersViewModel() { ID = x.ID, CustomerName = x.CustomerName, Phone = x.Phone, Email = x.Email, ProvinceID = x.ProvinceID, RegionID = x.RegionID, DistrictID = x.DistrictID, Address = x.Address, CreatedBy = x.CreatedBy, CreatedOn = x.CreatedOn, ModifiedBy = x.ModifiedBy, ModifiedOn = x.ModifiedOn, BirthDate = x.BirthDate, }).OrderBy(x => x.CustomerName).Take(10).ToList(); } return(result); }
public AddingToCartTest() { this._context = AddingToCartTest.GenerateMockContextData(); this._validator = new POSItemValidator(); this._cartValidator = new TransactionRequestValidator(); this._cart = AddingToCartTest.GenerateTransactionContext(); }
public static CustomersViewModel GetDataById(int iId) { CustomersViewModel result = new CustomersViewModel(); using (POSContext context = new POSContext()) { result = (from x in context.TCustomers where x.ID == iId select new CustomersViewModel() { ID = x.ID, CustomerName = x.CustomerName, Phone = x.Phone, Email = x.Email, ProvinceID = x.ProvinceID, RegionID = x.RegionID, DistrictID = x.DistrictID, Address = x.Address, CreatedBy = x.CreatedBy, CreatedOn = x.CreatedOn, ModifiedBy = x.ModifiedBy, ModifiedOn = x.ModifiedOn, BirthDate = x.BirthDate, }).FirstOrDefault(); } return(result); }
//untuk search items public static List <TransferViewModel> GetDataSearch(string SearchKey) { List <TransferViewModel> result = new List <TransferViewModel>(); using (POSContext context = new POSContext()) { result = (from ts in context.TTransferStock join tsd in context.TTransferStockDetail on ts.ID equals tsd.HeaderID join iv in context.TItemsVariant on tsd.VariantID equals iv.ID join ii in context.TItemsIventory on iv.ID equals ii.VariantID where iv.VariantName.Contains(SearchKey) || iv.SKU.Contains(SearchKey) select new TransferViewModel() { ID = iv.ID, FromOutlet = ts.FromOutlet, ToOutlet = ts.ToOutlet, Note = ts.Note, HeaderID = ts.ID, //InStock = ii.Beginning, //Quantity = ii.Transfer, VariantName = iv.VariantName, //SKU = iv.SKU, }).OrderBy(iv => iv.VariantName).Take(10).ToList(); //.OrderBy(iv => iv.VariantName) ==>>> ditempakan sebelum take } return(result); }
public static EmployeeOutletViewModel GetDataOutletByUserId(int userId) { EmployeeOutletViewModel result = new EmployeeOutletViewModel(); using (POSContext context = new POSContext()) { result = (from a in context.TEmployeeOutlet join b in context.TEmployee on a.EmployeeID equals b.ID join c in context.TUser on b.Email equals c.Email join d in context.TOutlet on a.OutletID equals d.ID where c.Id == userId select new EmployeeOutletViewModel() { ID = a.ID, OutletID = a.OutletID, EmployeeID = a.EmployeeID, RoleID = a.RoleID, OutletName = d.OutletName, CreatedBy = a.CreatedBy, CreatedOn = a.CreatedOn, ModifiedBy = a.ModifiedBy, ModifiedOn = a.ModifiedOn } ).FirstOrDefault(); } return(result); }
public InventoryService(IOptions <Settings> settings) { optionsBuilder.UseSqlServer(settings.Value.ConnectionString.DefaultConnection); _context = new POSContext(optionsBuilder.Options); _settings = settings.Value; }
public ActionResult Customers(IEnumerable <Customer> customers) { using (var context = new POSContext()) { var customersList = context.Customers.ToList(); return(View(customersList)); } }
public TransactionBehaviour(POSContext dbContext, IPOSServiceIntegrationEventService posServiceIntegrationEventService, ILogger <TransactionBehaviour <TRequest, TResponse> > logger) { _dbContext = dbContext ?? throw new ArgumentException(nameof(POSContext)); _posServiceIntegrationEventService = posServiceIntegrationEventService ?? throw new ArgumentException(nameof(posServiceIntegrationEventService)); _logger = logger ?? throw new ArgumentException(nameof(ILogger)); }
public ServiceLocator(POSContext _context) { services = new Dictionary <object, object>(); ///Register Service services.Add(typeof(IAdminShopService), new AdminShopService(_context)); services.Add(typeof(IShopStatusService), new ShopStatusService(_context)); services.Add(typeof(IAdminRegionService), new AdminRegionService(_context)); }
public ActionResult Create() { using (var context = new POSContext()) { var viewModel = new ViewModel(); viewModel.Addresses = context.Addresses.ToList(); return(View(viewModel)); } }
private static POSContext AddItem(POSContext context, POSItems item) { if (!context.Items.Any(e => e.Id == item.Id)) { context.Add(item); context.SaveChanges(); } return(context); }
public MerchantController( ILogger <MerchantController> logger, IMapper mapper, POSContext context) { this._logger = logger; this._mapper = mapper; this._context = context; }