public List <SStoreModels> GetListStores(string StoreID = null, string ID = null, List <string> lstOrgs = null) { List <SStoreModels> listdata = new List <SStoreModels>(); try { StoreApiModel paraBody = new StoreApiModel(); paraBody.ListOrganizations = lstOrgs; paraBody.StoreId = StoreID; paraBody.Id = (!string.IsNullOrEmpty(ID) ? ID : StoreID); var result = (ResponseApiModels)ApiResponse.Post <ResponseApiModels>(Commons.GetStores, null, paraBody); dynamic data = result.Data; var lstZ = data["ListStore"]; var lstContent = JsonConvert.SerializeObject(lstZ /*result.RawData*/); listdata = JsonConvert.DeserializeObject <List <SStoreModels> >(lstContent); var currentUser = (UserSession)System.Web.HttpContext.Current.Session["User"]; if (currentUser != null) { listdata = listdata.Where(x => currentUser.ListStoreID.Contains(x.ID)).ToList(); } if (listdata != null && listdata.Any()) { listdata = listdata.OrderBy(oo => oo.Name).ToList(); } return(listdata); } catch (Exception e) { _logger.Error("Store_GetList: " + e); return(listdata); } }
public StoreApiModel Post([FromBody] StoreApiModel store) { try { //idenity user var identity = (ClaimsIdentity)User.Identity; var name = identity.Claims.Where(x => x.Type == ClaimTypes.Name).Single().Value; //identity user/ store.ModifiedUser = name; store.UserName = name; var newstore = _business.CreateStore(ApiTranslators.Translate <StoreApiModel, StoreDTO>(store)); return(ApiTranslators.Translate <StoreDTO, StoreApiModel>(newstore)); } catch { return(null); } }
public IHttpActionResult Put([FromBody] StoreApiModel store) { try { var identity = (ClaimsIdentity)User.Identity; var name = identity.Claims.Where(x => x.Type == ClaimTypes.Name).Single().Value; var result = _business.Put(ApiTranslators.Translate <StoreApiModel, StoreDTO>(store), name); if (result) { return(Ok(result)); } else { return(BadRequest()); } } catch { return(BadRequest("false")); } }
public Models.StatusResponse Export(ref IXLWorksheet ws, List <string> lstStore) { Models.StatusResponse Response = new Models.StatusResponse(); try { List <SStoreModels> listData = new List <SStoreModels>(); StoreApiModel paraBody = new StoreApiModel(); paraBody.AppKey = Commons.AppKey; paraBody.AppSecret = Commons.AppSecret; paraBody.CreatedUser = Commons.CreateUser; paraBody.ListStoreID = lstStore; var result = (ResponseApiModels)ApiResponse.Post <ResponseApiModels>(Commons.ExportStore, null, paraBody); dynamic data = result.Data; var lstC = data["ListStore"]; var lstContent = JsonConvert.SerializeObject(lstC); listData = JsonConvert.DeserializeObject <List <SStoreModels> >(lstContent); ws.Cell("A" + 1).Value = _AttributeForLanguage.CurrentUser.GetLanguageTextFromKey("Store Information").ToString().ToUpper(); ws.Row(1).Style.Font.SetBold(true); ws.Row(1).Height = 20; ws.Row(1).Style.Font.FontSize = 15; ws.Range(1, 1, 1, 18).Merge(); ws.Cell("A" + 1).Style.Fill.SetBackgroundColor(XLColor.FromHtml(Commons.BgColorHeader)); int row = 2; string[] listSetMenuHeader = new string[] { _AttributeForLanguage.CurrentUser.GetLanguageTextFromKey("Index"), _AttributeForLanguage.CurrentUser.GetLanguageTextFromKey("Store Name"), _AttributeForLanguage.CurrentUser.GetLanguageTextFromKey("Phone"), _AttributeForLanguage.CurrentUser.GetLanguageTextFromKey("Email"), _AttributeForLanguage.CurrentUser.GetLanguageTextFromKey("Street"), _AttributeForLanguage.CurrentUser.GetLanguageTextFromKey("Stage/Province"), _AttributeForLanguage.CurrentUser.GetLanguageTextFromKey("Country"), _AttributeForLanguage.CurrentUser.GetLanguageTextFromKey("Zip Code"), _AttributeForLanguage.CurrentUser.GetLanguageTextFromKey("GST Reg No"), _AttributeForLanguage.CurrentUser.GetLanguageTextFromKey("Time Zone"), _AttributeForLanguage.CurrentUser.GetLanguageTextFromKey("Active"), _AttributeForLanguage.CurrentUser.GetLanguageTextFromKey("Monday"), _AttributeForLanguage.CurrentUser.GetLanguageTextFromKey("Tuesday"), _AttributeForLanguage.CurrentUser.GetLanguageTextFromKey("Wednesday"), _AttributeForLanguage.CurrentUser.GetLanguageTextFromKey("Thursday"), _AttributeForLanguage.CurrentUser.GetLanguageTextFromKey("Friday"), _AttributeForLanguage.CurrentUser.GetLanguageTextFromKey("Saturday"), _AttributeForLanguage.CurrentUser.GetLanguageTextFromKey("Sunday"), }; for (int i = 1; i <= listSetMenuHeader.Length; i++) { ws.Cell(row, i).Value = listSetMenuHeader[i - 1]; ws.Cell(row, i).Style.Font.Bold = true; } int cols = listSetMenuHeader.Length; //Item row = 3; int countIndex = 1; foreach (var item in listData) { ws.Cell("A" + row).Value = countIndex; ws.Cell("B" + row).Value = item.Name; ws.Cell("C" + row).Value = "'" + item.Phone; ws.Cell("D" + row).Value = item.Email; ws.Cell("E" + row).Value = item.Street; ws.Cell("F" + row).Value = "'" + item.City; ws.Cell("G" + row).Value = "'" + item.Country; ws.Cell("H" + row).Value = "'" + item.Zipcode; ws.Cell("I" + row).Value = "'" + item.GSTRegNo; ws.Cell("J" + row).Value = "'" + item.TimeZone; ws.Cell("K" + row).Value = item.IsActive ? _AttributeForLanguage.CurrentUser.GetLanguageTextFromKey("Active") : _AttributeForLanguage.CurrentUser.GetLanguageTextFromKey("InActive"); var b = "OFF-OFF"; if (item.ListBusinessHour != null) { item.ListBusinessHour = item.ListBusinessHour.OrderBy(x => x.Day).ToList(); item.GetTime(); var a = ""; for (int i = 0; i < item.ListBusinessHour.Count; i++) { if (!(item.ListBusinessHour[i].IsOffline)) { a = item.ListBusinessHour[i].FromTime.ToLocalTime().ToString("HH:mm") + " - " + item.ListBusinessHour[i].ToTime.ToLocalTime().ToString("HH:mm"); } else { a = _AttributeForLanguage.CurrentUser.GetLanguageTextFromKey("OFF") + "-" + _AttributeForLanguage.CurrentUser.GetLanguageTextFromKey("OFF"); } //======== if (item.ListBusinessHour[i].Day == 2) { ws.Cell("L" + row).Value = a; } else if (item.ListBusinessHour[i].Day == 3) { ws.Cell("M" + row).Value = a; } else if (item.ListBusinessHour[i].Day == 4) { ws.Cell("N" + row).Value = a; } else if (item.ListBusinessHour[i].Day == 5) { ws.Cell("O" + row).Value = a; } else if (item.ListBusinessHour[i].Day == 6) { ws.Cell("P" + row).Value = a; } else if (item.ListBusinessHour[i].Day == 7) { ws.Cell("Q" + row).Value = a; } else if (item.ListBusinessHour[i].Day == 8) { ws.Cell("R" + row).Value = a; } } } else { ws.Cell("L" + row).Value = b; ws.Cell("M" + row).Value = b; ws.Cell("N" + row).Value = b; ws.Cell("O" + row).Value = b; ws.Cell("P" + row).Value = b; ws.Cell("Q" + row).Value = b; ws.Cell("R" + row).Value = b; } row++; countIndex++; } FormatExcelExport(ws, row, cols); Response.Status = true; } catch (Exception e) { Response.Status = false; Response.MsgError = e.Message; } finally { } return(Response); }
public bool InsertOrUpdateStore(SStoreModels model) { try { StoreApiModel paraBody = new StoreApiModel(); SStoreModels store = new SStoreModels(); store.ID = model.ID; store.Name = model.Name; store.ImageURL = model.ImageURL; store.Email = model.Email; store.Street = model.Street; store.City = model.City; store.Country = model.Country; store.TimeZone = model.TimeZone; store.IsActive = model.IsActive; store.ListBusinessHour = model.ListBusinessHour; store.OrganizationID = model.OrganizationID; store.CompanyID = model.CompanyID; store.IndustryID = model.IndustryID; store.Description = model.Description; store.ExceptionData = model.ExceptionData; store.Code = model.Code; store.Phone = model.Phone; store.Zipcode = model.Zipcode; store.GSTRegNo = model.GSTRegNo; store.StoreCode = model.StoreCode; //=================== paraBody.Store = store; paraBody.AppKey = Commons.AppKey; paraBody.AppSecret = Commons.AppSecret; paraBody.CreatedUser = Commons.CreateUser; paraBody.Mode = 1; paraBody.RegisterToken = new RegisterTokenModels(); paraBody.StoreId = model.ID; paraBody.Id = model.ID; //==================== var result = (ResponseApiModels)ApiResponse.Post <ResponseApiModels>(Commons.CreateOrEditStore, null, paraBody); if (result != null) { if (result.Success) { return(true); } else { _logger.Error(result.Message); return(false); } } else { _logger.Error(result); return(false); } } catch (Exception e) { _logger.Error("Stores_InsertOrUpdate: " + e); return(false); } }