public async Task <IActionResult> create(userLoginList userLoginList) { try { List <UserLogin> list = userLoginList.UserList; for (int i = 0; i < list.Count; i++) { bool dataexist = _context.UserLogin.Any(c => c.UserId == list[i].UserId); if (!dataexist) { UserLogin login = new UserLogin(); string password = list[i].OldPassword; byte[] passwordHash, passwordSalt; CreatePasswordHash(password, out passwordHash, out passwordSalt); login.PasswordHash = passwordHash; login.PasswordSalt = passwordSalt; //login.ConfirmPassword = list[i].ConfirmPassword; //login.NewPassword = password; login.OldPassword = password; login.Role = list[i].Role; _context.Add(login); _context.SaveChanges(); CreateStoreifexist(login.UserId, login.Id); } else { return(StatusCode(404, new { status = "404", create = false, message = "Cannot create a record, user id already exist." })); } } return(StatusCode(200, new { status = "200", create = true, message = "Created successfully!" })); } catch (Exception ex) { return(StatusCode(500, new { status = "500", create = false, message = ex.ToString() })); } }
public async Task <IActionResult> Post([FromBody] ClosingShiftAPI transactionApi) { CashierShift cashierShift = new CashierShift(); cashierShift.CashierShiftId = transactionApi.closingShiftId; cashierShift.DeviceName = transactionApi.deviceName; cashierShift.EmployeeCode = transactionApi.employeeId; cashierShift.EmployeeName = transactionApi.employeeName; cashierShift.OpeningTime = DateTime.Now; cashierShift.OpeningBalance = transactionApi.openingTransBal; cashierShift.ShiftCode = transactionApi.shiftCode; cashierShift.ShiftName = transactionApi.shiftCode + " - " + transactionApi.employeeName; cashierShift.ClosingBalance = transactionApi.closingTransBal; cashierShift.StoreCode = transactionApi.storeCode; cashierShift.StoreName = _context.Store.Where(c => c.Code == transactionApi.storeCode).First().Name; cashierShift.ClosingTime = DateTime.Now; _context.Add(cashierShift); //log record LogRecord log = new LogRecord(); log.TimeStamp = DateTime.Now; log.Tag = "Closing Shift"; log.Message = JsonConvert.SerializeObject(transactionApi); _context.LogRecord.Add(log); _context.SaveChanges(); this.sequenceNumber(transactionApi); return(Ok(cashierShift)); }
private InventoryLines createdInventory(DeliveryOrder transactionApi, int i) { InventoryLines inventory = new InventoryLines(); inventory.WarehouseId = transactionApi.warehouseTo; inventory.Qty = 0; inventory.ItemId = transactionApi.deliveryOrderLines[i].articleIdFk; _context.Add(inventory); _context.SaveChanges(); return(inventory); }
public async Task <IActionResult> create(discountSetupStoreList discSetupStoreList) { try { List <DiscountSetupStore> list = discSetupStoreList.discSetupStore; for (int i = 0; i < list.Count; i++) { bool discExist = false; bool storeExist = false; discExist = _context.DiscountSetup.Any(c => c.Id == list[i].DiscountId); var store = _context.Store.Where(x => x.Code == list[i].Store.Code).First(); storeExist = _context.DiscountSetupStore.Any(c => c.StoreId == store.Id); if (discExist && !storeExist) { DiscountSetupStore setupStore = new DiscountSetupStore(); setupStore.DiscountId = list[i].DiscountId; setupStore.StoreId = store.Id; _context.Add(setupStore); _context.SaveChanges(); } else { return(StatusCode(404, new { status = "404", create = false, message = "Cannot create a record, store id already exist or discount id not exist." })); } } return(StatusCode(200, new { status = "200", create = true, message = "Created successfully!" })); } catch (Exception ex) { return(StatusCode(500, new { status = "500", create = false, message = ex.ToString() })); } }
public async Task <IActionResult> create(ListPrice listPrice) { try { List <PriceList> list = listPrice.prices; for (int i = 0; i < list.Count; i++) { PriceList price = new PriceList(); price.ItemId = list[i].ItemId; price.SalesPrice = list[i].SalesPrice; price.Currency = list[i].Currency; _context.Add(price); bool discExist = false; discExist = _context.PriceList.Any(c => c.ItemId == price.ItemId); if (discExist == false) { _context.SaveChanges(); } else { return(StatusCode(404, new { status = "404", create = false, message = "Cannot create a record, item number already exist." })); } } return(StatusCode(200, new { status = "200", create = true, message = "Created successfully!" })); } catch (Exception ex) { return(StatusCode(500, new { status = "500", create = false, message = ex.ToString() })); } }
public async Task <IActionResult> create(discountSetupLineList discSetupLnList) { try { List <DiscountSetupLines> list = discSetupLnList.discountLines; for (int i = 0; i < list.Count; i++) { var discSetup = _context.DiscountSetup.Where(x => x.DiscountCode == list[i].DiscountCode).First(); DiscountSetupLines discSetupLines = new DiscountSetupLines(); discSetupLines.DiscountCode = list[i].DiscountCode; discSetupLines.GroupCode = list[i].GroupCode; discSetupLines.Code = list[i].Code; discSetupLines.DiscountPrecentage = list[i].DiscountPrecentage; discSetupLines.DiscountCash = list[i].DiscountCash; discSetupLines.QtyMin = list[i].QtyMin; discSetupLines.QtyMax = list[i].QtyMax; discSetupLines.AmountMin = list[i].AmountMin; discSetupLines.AmountMax = list[i].AmountMax; discSetupLines.ArticleIdDiscount = list[i].ArticleIdDiscount; discSetupLines.Multi = list[i].Multi; discSetupLines.DiscountSetupId = discSetup.Id; discSetupLines.CreatedDate = DateTime.Now; _context.Add(discSetupLines); _context.SaveChanges(); } return(StatusCode(200, new { status = "200", create = true, message = "created successfully!" })); } catch (Exception ex) { return(StatusCode(500, new { status = "500", create = false, message = ex.ToString() })); } }
public async Task <IActionResult> PostTransaction([FromBody] StockTakeAPI transactionApi) { APIResponse response = new APIResponse(); try { StockTake stockTake = new StockTake(); stockTake.EmployeeId = transactionApi.employeeId; stockTake.EmployeeName = transactionApi.employeeName; stockTake.Time = DateTime.Now; stockTake.StoreId = transactionApi.storeCode; _context.StockTake.Add(stockTake); //log record LogRecord log = new LogRecord(); log.TimeStamp = DateTime.Now; log.Tag = "Stock take"; log.Message = JsonConvert.SerializeObject(transactionApi); _context.LogRecord.Add(log); _context.SaveChanges(); for (int i = 0; i < transactionApi.stockTakeLines.Count; i++) { StockTakeLineAPI lineAPI = transactionApi.stockTakeLines[i]; StockTakeLine line = new StockTakeLine(); line.ArticleId = lineAPI.article.articleId; line.ArticleName = lineAPI.article.articleName; line.GoodQty = lineAPI.goodQty; line.RejectQty = lineAPI.rejectQty; line.WhGoodQty = lineAPI.whGoodQty; line.WhRejectQty = lineAPI.whRejectQty; line.StockTakeId = stockTake.Id; _context.Add(line); _context.SaveChanges(); } response.code = "1"; response.message = "Sucess Add Data"; } catch (Exception ex) { response.code = "0"; response.message = ex.ToString(); } return(Ok(response)); }
public async Task <IActionResult> Post([FromBody] ClosingStoreAPI transactionApi) { //log record LogRecord log = new LogRecord(); log.TimeStamp = DateTime.Now; log.Tag = "Closing Store"; log.Message = JsonConvert.SerializeObject(transactionApi); _context.LogRecord.Add(log); ClosingStore cashierShift = new ClosingStore(); cashierShift.ClosignTranBal = transactionApi.closingDeposit; cashierShift.ClosingDeposit = transactionApi.closingDeposit; cashierShift.ClosingPettyCash = transactionApi.closingDeposit; cashierShift.ClosingStoreId = transactionApi.closingStoreId; cashierShift.ClosingTimeStamp = DateTime.Now; cashierShift.DeviceName = transactionApi.deviceName; cashierShift.DisputePettyCash = transactionApi.disputePettyCash; cashierShift.DisputeTransBal = transactionApi.disputeTransBal; cashierShift.EmployeeId = transactionApi.employeeId; cashierShift.EmployeeName = transactionApi.employeeName; cashierShift.OpeningDeposit = transactionApi.openingDeposit; cashierShift.OpeningPettyCash = transactionApi.openingPettyCash; cashierShift.OpeningTimeStamp = DateTime.Now; cashierShift.OpeningTransBal = transactionApi.openingTransBal; cashierShift.RealDeposit = transactionApi.realDeposit; cashierShift.RealPettyCash = transactionApi.realPettyCash; cashierShift.RealTransBal = transactionApi.realTransBal; cashierShift.StatusClose = transactionApi.statusClose; cashierShift.StoreCode = transactionApi.storeCode; _context.Add(cashierShift); _context.SaveChanges(); this.sequenceNumber(transactionApi); return(Ok(cashierShift)); }
public async Task <IActionResult> create(BudgetList budgetList) { try { List <Budget> list = budgetList.Budgets; for (int i = 0; i < list.Count; i++) { Budget budget = new Budget(); budget.StoreCode = list[i].StoreCode; budget.StoreId = list[i].StoreId; budget.StoreName = list[i].StoreName; budget.Amount = list[i].Amount; budget.JournalNumber = list[i].JournalNumber; budget.TransactionDate = list[i].TransactionDate; _context.Add(budget); _context.SaveChanges(); } return(StatusCode(200, new { status = "200", create = true, message = "Created successfully!" })); } catch (Exception ex) { return(StatusCode(500, new { status = "500", create = false, message = ex.ToString() })); } }
public async Task <IActionResult> create(discountSetupList discSetupList) { try { List <DiscountSetup> list = discSetupList.discounts; for (int i = 0; i < list.Count; i++) { DiscountSetup discSetup = new DiscountSetup(); discSetup.DiscountCode = list[i].DiscountCode; discSetup.DiscountName = list[i].DiscountName; discSetup.DiscountCategory = list[i].DiscountCategory; discSetup.CustomerGroupId = list[i].CustomerGroupId; discSetup.DiscountCash = list[i].DiscountCash; discSetup.DiscountPercent = list[i].DiscountPercent; discSetup.DiscountType = list[i].DiscountType; discSetup.AmountMin = list[i].AmountMin; discSetup.AmountMax = list[i].AmountMax; discSetup.QtyMin = list[i].QtyMin; discSetup.QtyMax = list[i].QtyMax; discSetup.StartDate = list[i].StartDate; discSetup.EndDate = list[i].EndDate; discSetup.Multi = list[i].Multi; discSetup.ApprovedDate = list[i].ApprovedDate; discSetup.Status = list[i].Status; discSetup.CreatedDate = DateTime.Now; _context.Add(discSetup); bool discExist = false; discExist = _context.DiscountSetup.Any(c => c.DiscountCode == discSetup.DiscountCode); if (discExist == false) { _context.SaveChanges(); } else { return(StatusCode(404, new { status = "404", create = false, message = "Cannot create a record, discount code already exist." })); } } return(StatusCode(200, new { status = "200", create = true, message = "Created successfully!" })); } catch (Exception ex) { return(StatusCode(500, new { status = "500", create = false, message = ex.ToString() })); } }
public async Task <IActionResult> PostTransaction([FromBody] PettyCash transactionApi) { int orno = 0; //insert storeCode bool isStoreExist = _context.ExpenseStore.Any(c => c.StoreCode == transactionApi.storeCode); if (!isStoreExist) { ExpenseStore expenseStore = new ExpenseStore(); expenseStore.StoreCode = transactionApi.storeCode; expenseStore.RemaingBudget = 0; expenseStore.TotalExpense = 0; expenseStore.Year = DateTime.Now.Year; _context.ExpenseStore.Add(expenseStore); } APIResponse response = new APIResponse(); try { //perbaiki transaksi petty cash //add more unit; orno = _context.Expense.Count() + transactionApi.pettyCashLine.Count(); InforAPIPettyCash inforAPIPettyCash = new InforAPIPettyCash(_context); String itrn = inforAPIPettyCash.getRoundNumber(); foreach (PettyCashLine pl in transactionApi.pettyCashLine) { Expense expense = new Expense(); expense.Amount = (pl.price * pl.quantity); expense.CostCategoryId = transactionApi.expenseCategoryId; expense.CostCategoryName = transactionApi.expenseCategory; expense.ExpenseName = pl.expenseName; expense.StoreCode = transactionApi.storeCode; expense.Price = pl.price; expense.Qty = pl.quantity; expense.TypeId = Config.RetailEnum.expenseExpense; expense.TypeName = "Expense"; expense.Orno = "PC" + orno; expense.Itrn = itrn; try { expense.TransactionDate = DateTime.ParseExact(transactionApi.timeStamp, "MMM dd, yyyy h:mm:ss tt", CultureInfo.InvariantCulture); } catch { expense.TransactionDate = DateTime.ParseExact(transactionApi.date + transactionApi.time, "yyyy-MM-dd" + "H:mm:ss", CultureInfo.InvariantCulture); } _context.Add(expense); _context.SaveChanges(); } //log record this.updateExpense(transactionApi.storeCode); //post to infor inforAPIPettyCash.postPettyCash(transactionApi, orno, itrn).Wait(); response.code = "1"; response.message = "Sucess Add Data"; this.sequenceNumber(transactionApi); } catch (Exception ex) { response.code = "0"; response.message = ex.ToString(); } LogRecord log = new LogRecord(); log.TimeStamp = DateTime.Now; log.Tag = "Petty Cash"; log.Message = JsonConvert.SerializeObject(transactionApi); _context.LogRecord.Add(log); _context.SaveChanges(); return(Ok(response)); }