public ActionResult Index(MerchantConfigApiModels input) { var result = _pOSMerchantConfigFactory.UpdateTimeSettingForFJDailySale(input); ViewBag.result = "Update Successfully!"; return(View(input)); }
public bool UpdateTimeSettingForFJDailySale(MerchantConfigApiModels model) { using (var cxt = new NuWebContext()) { try { var result = cxt.G_POSAPIMerchantConfig.Where(ww => ww.Id == model.Id) .FirstOrDefault(); if (result != null) { result.MorningStart = model.MorningStart; result.MorningEnd = model.MorningEnd; result.MidDayStart = model.MidDayStart; result.MidDayEnd = model.MidDayEnd; cxt.SaveChanges(); } NSLog.Logger.Info("UpdateTimeSettingForFJDailySale", result); return(true); } catch (Exception ex) { NSLog.Logger.Error("GetTimeSettingForFJDailySale", ex); return(false); } } }
public ResponeMerchantConfig RegisterAccountFromCSC(MerchantConfigApiModels info) { //_logger.Info(info); NSLog.Logger.Info("Start [RegisterAccountFromCSC] data.......................", info); var response = new ResponeMerchantConfig(); if (info != null) { response = _POSMerchantConfigFactory.RegisterAccountFromCSC(info); } return(response); }
public ResponeMerchantConfig InsertPosApiMerchantConfig(MerchantConfigApiModels info) { //_logger.Info(info); NSLog.Logger.Info("Start [Insert Pos Api Merchant Config] data.......................", info); var respoone = new ResponeMerchantConfig(); if (info != null) { respoone = _POSMerchantConfigFactory.Insert(info); } return(respoone); }
public ActionResult Index() { MerchantConfigApiModels model = _pOSMerchantConfigFactory.GetTimeSettingForFJDailySale(CurrentUser.HostApi); return(View(model)); }
/*Merchant*/ public ResponeMerchantConfig Insert(MerchantConfigApiModels info) { ResponeMerchantConfig result = new ResponeMerchantConfig(); using (NuWebContext cxt = new NuWebContext()) { using (var transaction = cxt.Database.BeginTransaction()) { try { var isExsitMerchant = cxt.G_POSAPIMerchantConfig.Any(x => x.POSAPIUrl.ToLower().Equals(info.POSAPIUrl.ToLower())); if (isExsitMerchant) { NSLog.Logger.Info(string.Format("The merchant [{0}] already exist", info.POSAPIUrl)); return(result); } G_POSAPIMerchantConfig itemMerchantConfig = new G_POSAPIMerchantConfig(); /*string POSAPIMerchantConfigId =Guid.NewGuid().ToString();*/ string POSAPIMerchantConfigId = string.Empty; if (string.IsNullOrEmpty(info.Id)) { POSAPIMerchantConfigId = Guid.NewGuid().ToString(); } else { POSAPIMerchantConfigId = info.Id; } itemMerchantConfig.Id = POSAPIMerchantConfigId; itemMerchantConfig.NuPOSInstance = info.NuPOSInstance; itemMerchantConfig.POSAPIUrl = info.POSAPIUrl; itemMerchantConfig.FTPHost = info.FTPHost; itemMerchantConfig.FTPUser = info.FTPUser; itemMerchantConfig.FTPPassword = info.FTPPassword; itemMerchantConfig.ImageBaseUrl = info.ImageBaseUrl; itemMerchantConfig.BreakfastStart = info.BreakfastStart; itemMerchantConfig.BreakfastEnd = info.BreakfastEnd; itemMerchantConfig.LunchStart = info.LunchStart; itemMerchantConfig.LunchEnd = info.LunchEnd; itemMerchantConfig.DinnerStart = info.DinnerStart; itemMerchantConfig.DinnerEnd = info.DinnerEnd; itemMerchantConfig.CreatedDate = DateTime.Now; itemMerchantConfig.IsActived = true; itemMerchantConfig.POSInstanceVersion = info.POSInstanceVersion; itemMerchantConfig.MorningStart = info.MorningStart; itemMerchantConfig.MorningEnd = info.MorningEnd; itemMerchantConfig.MidDayStart = info.MidDayStart; itemMerchantConfig.MidDayEnd = info.MidDayEnd; List <G_POSEmployeeConfig> lstInsertEmployee = new List <G_POSEmployeeConfig>(); G_POSEmployeeConfig itemEmpInsert = null; foreach (var item in info.ListEmployees) { itemEmpInsert = new G_POSEmployeeConfig(); if (string.IsNullOrEmpty(item.Id)) { itemEmpInsert.Id = Guid.NewGuid().ToString(); } else { itemEmpInsert.Id = item.Id; } //itemEmpInsert.Id = Guid.NewGuid().ToString(); itemEmpInsert.POSAPIMerchantConfigId = POSAPIMerchantConfigId; itemEmpInsert.UserName = item.UserName; itemEmpInsert.Password = CommonHelper.GetSHA512(item.Password); itemEmpInsert.CreatedDate = DateTime.Now; itemEmpInsert.IsActived = true; lstInsertEmployee.Add(itemEmpInsert); } cxt.G_POSAPIMerchantConfig.Add(itemMerchantConfig); cxt.G_POSEmployeeConfig.AddRange(lstInsertEmployee); cxt.SaveChanges(); transaction.Commit(); result.IsOk = true; result.POSIntanceID = itemMerchantConfig.Id; NSLog.Logger.Info("Insert [Insert Pos Api Merchant Config] data success", info); } catch (Exception ex) { NSLog.Logger.Error("Insert [Insert Pos Api Merchant Config] data fail", ex); //_logger.Error(ex); result.IsOk = false; transaction.Rollback(); } finally { if (cxt != null) { cxt.Dispose(); } } } } //var jsonContent = JsonConvert.SerializeObject(info); //_baseFactory.InsertTrackingLog("G_POSAPIMerchantConfig", jsonContent, info.NuPOSInstance, result); return(result); }
//2018-01-02 public ResponeMerchantConfig RegisterAccountFromCSC(MerchantConfigApiModels info) { ResponeMerchantConfig result = new ResponeMerchantConfig(); using (NuWebContext cxt = new NuWebContext()) { using (var transaction = cxt.Database.BeginTransaction()) { try { var merchant = cxt.G_POSAPIMerchantConfig.Where(x => x.POSAPIUrl == info.POSAPIUrl && x.IsActived).FirstOrDefault(); if (merchant != null) { List <G_POSEmployeeConfig> lstInsertEmployee = new List <G_POSEmployeeConfig>(); G_POSEmployeeConfig itemEmpInsert = null; foreach (var item in info.ListEmployees) { itemEmpInsert = new G_POSEmployeeConfig(); if (string.IsNullOrEmpty(item.Id)) { itemEmpInsert.Id = Guid.NewGuid().ToString(); } else { itemEmpInsert.Id = item.Id; } itemEmpInsert.POSAPIMerchantConfigId = merchant.Id; itemEmpInsert.UserName = item.UserName; itemEmpInsert.Password = item.Password; itemEmpInsert.CreatedDate = DateTime.Now; itemEmpInsert.IsActived = true; lstInsertEmployee.Add(itemEmpInsert); } cxt.G_POSEmployeeConfig.AddRange(lstInsertEmployee); } else { G_POSAPIMerchantConfig itemMerchantConfig = new G_POSAPIMerchantConfig(); itemMerchantConfig.Id = info.Id; itemMerchantConfig.NuPOSInstance = info.NuPOSInstance; itemMerchantConfig.POSAPIUrl = info.POSAPIUrl; itemMerchantConfig.FTPHost = info.FTPHost; itemMerchantConfig.FTPUser = info.FTPUser; itemMerchantConfig.FTPPassword = info.FTPPassword; itemMerchantConfig.ImageBaseUrl = info.ImageBaseUrl; itemMerchantConfig.BreakfastStart = info.BreakfastStart; itemMerchantConfig.BreakfastEnd = info.BreakfastEnd; itemMerchantConfig.LunchStart = info.LunchStart; itemMerchantConfig.LunchEnd = info.LunchEnd; itemMerchantConfig.DinnerStart = info.DinnerStart; itemMerchantConfig.DinnerEnd = info.DinnerEnd; itemMerchantConfig.CreatedDate = DateTime.Now; itemMerchantConfig.IsActived = true; itemMerchantConfig.POSInstanceVersion = info.POSInstanceVersion; itemMerchantConfig.MorningStart = info.MorningStart; itemMerchantConfig.MorningEnd = info.MorningEnd; itemMerchantConfig.MidDayStart = info.MidDayStart; itemMerchantConfig.MidDayEnd = info.MidDayEnd; List <G_POSEmployeeConfig> lstInsertEmployee = new List <G_POSEmployeeConfig>(); G_POSEmployeeConfig itemEmpInsert = null; foreach (var item in info.ListEmployees) { itemEmpInsert = new G_POSEmployeeConfig(); if (string.IsNullOrEmpty(item.Id)) { itemEmpInsert.Id = Guid.NewGuid().ToString(); } else { itemEmpInsert.Id = item.Id; } //itemEmpInsert.Id = Guid.NewGuid().ToString(); itemEmpInsert.POSAPIMerchantConfigId = info.Id; itemEmpInsert.UserName = item.UserName; itemEmpInsert.Password = item.Password; itemEmpInsert.CreatedDate = DateTime.Now; itemEmpInsert.IsActived = true; lstInsertEmployee.Add(itemEmpInsert); } cxt.G_POSAPIMerchantConfig.Add(itemMerchantConfig); cxt.G_POSEmployeeConfig.AddRange(lstInsertEmployee); } cxt.SaveChanges(); transaction.Commit(); result.IsOk = true; result.POSIntanceID = info.Id; NSLog.Logger.Info("Insert [RegisterAccountFromCSC] data success", info); } catch (Exception ex) { NSLog.Logger.Error("Insert [RegisterAccountFromCSC] data fail", ex); //_logger.Error(ex); result.IsOk = false; transaction.Rollback(); } finally { if (cxt != null) { cxt.Dispose(); } } } } return(result); }
public ActionResult Report_Current(DailySalesViewModel model) { try { if (model.EndTime.Hours == 0) { model.EndTime = new TimeSpan(23, 59, 59); } /*end*/ DateTime dFrom = new DateTime(model.FromDate.Year, model.FromDate.Month, model.FromDate.Day, model.StartTime.Hours, model.StartTime.Minutes, 0) , dTo = new DateTime(model.ToDate.Year, model.ToDate.Month, model.ToDate.Day, model.EndTime.Hours, model.EndTime.Minutes, 59); FJDailySalesReportFactory factory = new FJDailySalesReportFactory(); if (dFrom > dTo) { ModelState.AddModelError("FromDate", CurrentUser.GetLanguageTextFromKey("From Date must be less than To Date.")); } else if (model.Type == Commons.TypeCompanySelected) //Company { if (model.ListCompanys == null) { ModelState.AddModelError("ListCompanys", CurrentUser.GetLanguageTextFromKey("Please choose company.")); } } else //Store { if (model.ListStores == null) { ModelState.AddModelError("ListStores", CurrentUser.GetLanguageTextFromKey("Please choose store.")); } } if (!ModelState.IsValid) { return(View("Index", model)); } //Get Selected Store List <StoreModels> lstStore = new List <StoreModels>(); ////if (model.Type == Commons.TypeCompanySelected) //Company ////{ //// lstStore = model.GetSelectedStoreCompany(); //// model.ListStores = lstStore.Select(ss => ss.Id).ToList(); ////} ////else //Store ////{ //// List<SelectListItem> vbStore = ViewBag.Stores; //// lstStore = model.GetSelectedStore(vbStore); ////} ///////======= Updated 072018 if (model.Type == Commons.TypeCompanySelected) //Company { lstStore = listStoresInfoSession.Where(ww => model.ListCompanys.Contains(ww.CompanyId)).ToList(); model.ListStores = lstStore.Select(ss => ss.Id).ToList(); } else //Store { lstStore = listStoresInfoSession.Where(ww => model.ListStores.Contains(ww.Id)).ToList(); } if (model.StartTime.Hours == 0 && model.StartTime.Minutes == 0 && model.EndTime.Hours == 0 && model.EndTime.Minutes == 0) { model.FromDate = new DateTime(model.FromDate.Year, model.FromDate.Month, model.FromDate.Day, 0, 0, 0); model.ToDate = new DateTime(model.ToDate.Year, model.ToDate.Month, model.ToDate.Day, 23, 59, 59); } else { model.FromDate = new DateTime(model.FromDate.Year, model.FromDate.Month, model.FromDate.Day, model.StartTime.Hours, model.StartTime.Minutes, 0); model.ToDate = new DateTime(model.ToDate.Year, model.ToDate.Month, model.ToDate.Day, model.EndTime.Hours, model.EndTime.Minutes, 59); } // Get setting time POSMerchantConfigFactory _pOSMerchantConfigFactory = new POSMerchantConfigFactory(); MerchantConfigApiModels pOSMerchantConfig = _pOSMerchantConfigFactory.GetTimeSettingForFJDailySale(CurrentUser.HostApi); //Export excel XLWorkbook wb = factory.ExportExcel(model, lstStore, pOSMerchantConfig); ViewBag.wb = wb; string sheetName = string.Format("Report_FJDaily_Sales_{0}", DateTime.Now.ToString("MMddyyyy")); Response.Clear(); Response.ClearContent(); Response.ClearHeaders(); Response.Charset = UTF8Encoding.UTF8.WebName; Response.ContentEncoding = UTF8Encoding.UTF8; if (model.FormatExport.Equals(Commons.Html)) { Response.AddHeader("content-disposition", String.Format(@"attachment;filename={0}.html", sheetName.Replace(" ", "_"))); } else { Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; Response.AddHeader("content-disposition", String.Format(@"attachment;filename={0}.xlsx", sheetName.Replace(" ", "_"))); } using (var memoryStream = new System.IO.MemoryStream()) { wb.SaveAs(memoryStream); if (model.FormatExport.Equals(Commons.Html)) { Workbook workbook = new Workbook(); workbook.LoadFromStream(memoryStream); //convert Excel to HTML Worksheet sheet = workbook.Worksheets[0]; using (var ms = new MemoryStream()) { sheet.SaveToHtml(ms); ms.WriteTo(HttpContext.Response.OutputStream); ms.Close(); } } else { memoryStream.WriteTo(HttpContext.Response.OutputStream); } memoryStream.Close(); } HttpContext.Response.End(); return(View("Index", model)); } catch (Exception ex) { _logger.Error("FJ Daily Sales Report Error: " + ex); return(new HttpStatusCodeResult(400, ex.Message)); } }