public ActionResult <CustomerAccountTE> GetCustomerAccount(string SearchValue) { string Searchvalue = SearchValue.Trim(); string Result = ""; CustomerAccountTE CustomerAccountInfo = new CustomerAccountTE(); CustomerAccountInfo = _context.customeraccounts.SingleOrDefault(x => x.Customerid == Searchvalue); if (CustomerAccountInfo == null) { var CustomerData = _context.customers.SingleOrDefault(x => x.customermobile == Searchvalue); if (CustomerData != null) { CustomerAccountInfo = _context.customeraccounts.SingleOrDefault(x => x.Customerid == CustomerData.CustomerId); if (CustomerAccountInfo != null) { return(Ok(CustomerAccountInfo)); } else { Result = "Customer Dont Have Account Credit"; return(Ok(Result)); } } else { Result = "Mobile or CustID doesn't match with any Customer"; return(Ok(Result)); } } else { return(Ok(CustomerAccountInfo)); } }
public ActionResult <String> CreateCustomerAccount([FromForm] CustomerAccountTE data) { string result = ""; //Fitst Time - Needs to check Any Data Available in CustomerAccount Table bool isDataAvailable = _context.customeraccounts.Any(); if (isDataAvailable) { var isCustAvailable = _context.customeraccounts.SingleOrDefault(x => x.Customerid == data.Customerid); if (isCustAvailable == null) { _context.Add(data); _context.SaveChanges(); result = "Account Created Successfully"; } else { result = "Account Available Already!"; } } else { //It will Run Just ontime for creating Table _context.Add(data); _context.SaveChanges(); result = "Account Created Successfully"; } return(Ok(result)); }
public ActionResult <String> SetCreditToCustomerAccount([FromForm] CustomerAccountTE data) { string Result = ""; var CustomerAccount = _context.customeraccounts.SingleOrDefault(x => x.Customerid == data.Customerid); if (CustomerAccount != null) { CustomerAccount.Availableamount += data.Availableamount; _context.Entry(CustomerAccount).State = Microsoft.EntityFrameworkCore.EntityState.Modified; _context.SaveChanges(); int MaxId = _context.cashposition.Max(x => x.Id); var CashPosition = _context.cashposition.Single(x => x.Id == MaxId); CashPosition.Globalcash += data.Availableamount; _context.Entry(CashPosition).State = Microsoft.EntityFrameworkCore.EntityState.Modified; _context.SaveChanges(); Result = "Credit Successfully"; } else { Result = "Failed"; } return(Ok(Result)); }
public ActionResult <CustomerAccountTE> GetCustomerAccount([FromForm] CustomerAccountTE data) { var CustomerAccountData = _context.customeraccounts.SingleOrDefault(x => x.Customerid == data.Customerid); return(Ok(CustomerAccountData)); }