예제 #1
0
        public PartialViewResult Edit(string id)
        {
            SStoreModels            model        = GetDetail(id);
            List <CountryApiModels> lstCountries = CommonHelper.GetListCountry();

            foreach (var country in lstCountries)
            {
                model.ListCountries.Add(new SelectListItem
                {
                    Value    = country.Name,
                    Text     = country.Name,
                    Selected = country.Name.Equals(model.Country) ? true : false
                });
            }
            model.ListTimezones = GetTimezonesOfCountry(lstCountries, model.Country, model.TimeZone);
            return(PartialView("_Edit", model));
        }
예제 #2
0
        public ActionResult Export(SStoreModels model)
        {
            try
            {
                if (model.ListStores == null)
                {
                    ModelState.AddModelError("ListStores", CurrentUser.GetLanguageTextFromKey("Please choose store"));
                    return(View(model));
                }

                XLWorkbook wb        = new XLWorkbook();
                var        wsSetMenu = wb.Worksheets.Add("Sheet1");
                Shared.Models.StatusResponse response = _factory.Export(ref wsSetMenu, model.ListStores);

                if (!response.Status)
                {
                    ModelState.AddModelError("", response.MsgError);
                    return(View(model));
                }

                ViewBag.wb = wb;
                Response.Clear();
                Response.ClearContent();
                Response.ClearHeaders();
                Response.Charset         = UTF8Encoding.UTF8.WebName;
                Response.ContentEncoding = UTF8Encoding.UTF8;
                Response.ContentType     = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
                Response.AddHeader("content-disposition", String.Format(@"attachment;filename={0}.xlsx",
                                                                        CommonHelper.GetExportFileName("StoreInformation").Replace(" ", "_")));

                using (var memoryStream = new System.IO.MemoryStream())
                {
                    wb.SaveAs(memoryStream);
                    memoryStream.WriteTo(HttpContext.Response.OutputStream);
                    memoryStream.Close();
                }
                HttpContext.Response.End();
                return(RedirectToAction("Export"));
            }
            catch (Exception e)
            {
                _logger.Error("StoreInformations_Export: " + e);
                return(new HttpStatusCodeResult(400, e.Message));
            }
        }
예제 #3
0
        // Updated 08312017
        public ActionResult LoadTimezones(string Country)
        {
            List <CountryApiModels> listCountries = CommonHelper.GetListCountry();
            SStoreModels            model         = new SStoreModels();
            var countryInfo = listCountries.Where(w => w.Name.Equals(Country)).FirstOrDefault();

            if (countryInfo != null)
            {
                foreach (string timeZone in countryInfo.Timezones)
                {
                    model.ListTimezones.Add(new SelectListItem
                    {
                        Text     = timeZone,
                        Value    = timeZone,
                        Selected = false
                    });
                }
            }
            return(PartialView("~/Views/SStoreInformation/_DropDownListTimezones.cshtml", model));
        }
예제 #4
0
        public SStoreModels GetDetail(string id)
        {
            try
            {
                SStoreModels model = _factory.GetListStores(null, id)[0];
                model.StoreID  = id;
                model.ImageURL = string.IsNullOrEmpty(model.ImageURL) ? Commons.Image100_100 : model.ImageURL;
                //=======Working Time
                if (model.ListBusinessHour != null)
                {
                    model.ListBusinessHour = model.ListBusinessHour.OrderBy(x => x.Day).ToList();
                    model.GetTime();
                    for (int i = 0; i < model.ListBusinessHour.Count; i++)
                    {
                        var item = model.ListBusinessHour[i];
                        if (item.IsOffline)
                        {
                            item.From = _AttributeForLanguage.CurrentUser.GetLanguageTextFromKey("OFF");
                            item.To   = _AttributeForLanguage.CurrentUser.GetLanguageTextFromKey("OFF");
                        }
                        else
                        {
                            item.From = item.FromTime.ToLocalTime().ToString("HH:mm");
                            item.To   = item.ToTime.ToLocalTime().ToString("HH:mm");
                        }
                        item.IsOffline = !item.IsOffline;
                        switch (item.Day)
                        {
                        case 2:
                            item.StrDate = _AttributeForLanguage.CurrentUser.GetLanguageTextFromKey("Mon");
                            break;

                        case 3:
                            item.StrDate = _AttributeForLanguage.CurrentUser.GetLanguageTextFromKey("Tue");
                            break;

                        case 4:
                            item.StrDate = _AttributeForLanguage.CurrentUser.GetLanguageTextFromKey("Wed");
                            break;

                        case 5:
                            item.StrDate = _AttributeForLanguage.CurrentUser.GetLanguageTextFromKey("Thu");
                            break;

                        case 6:
                            item.StrDate = _AttributeForLanguage.CurrentUser.GetLanguageTextFromKey("Fri");
                            break;

                        case 7:
                            item.StrDate = _AttributeForLanguage.CurrentUser.GetLanguageTextFromKey("Sat");
                            break;

                        case 8:
                            item.StrDate = _AttributeForLanguage.CurrentUser.GetLanguageTextFromKey("Sun");
                            break;
                        }
                    }
                }
                else
                {
                    model.GetValue();
                }
                return(model);
            }
            catch (Exception ex)
            {
                _logger.Error("StoreInformations_ Detail: " + ex);
                return(null);
            }
        }
예제 #5
0
        public ActionResult Export()
        {
            SStoreModels model = new SStoreModels();

            return(View(model));
        }
예제 #6
0
        public ActionResult Edit(SStoreModels model)
        {
            try
            {
                if (!string.IsNullOrEmpty(model.ImageURL))
                {
                    model.ImageURL = model.ImageURL.Replace(Commons._PublicImages, "").Replace(Commons.Image100_100, "");
                }

                if (model.PictureUpload != null && model.PictureUpload.ContentLength > 0)
                {
                    Byte[] imgByte = new Byte[model.PictureUpload.ContentLength];
                    model.PictureUpload.InputStream.Read(imgByte, 0, model.PictureUpload.ContentLength);
                    model.PictureByte   = imgByte;
                    model.ImageURL      = Guid.NewGuid() + Path.GetExtension(model.PictureUpload.FileName);
                    model.PictureUpload = null;
                }
                else
                {
                    model.ImageURL = model.ImageURL.Replace(Commons._PublicImages, "").Replace(Commons.Image100_100, "");
                }

                // Country
                // Updated 08292017
                string countryChoose = null;
                if (!string.IsNullOrEmpty(model.Country))
                {
                    countryChoose = model.Country;
                }

                // Updated 08312017
                string timeZoneChoose = null;
                if (!string.IsNullOrEmpty(model.TimeZone))
                {
                    timeZoneChoose = model.TimeZone;
                }

                //ListBusinessHour
                for (int i = 0; i < model.ListBusinessHour.Count; i++)
                {
                    var item = model.ListBusinessHour[i];

                    //item.IsOffline = (item.From.ToLower().Equals("off") || item.To.ToLower().Equals("off")) ? true : false;
                    //if (item.IsOffline)
                    //{
                    bool itemIsOff = (_AttributeForLanguage.CurrentUser.GetLanguageTextFromKey(item.From).Equals(_AttributeForLanguage.CurrentUser.GetLanguageTextFromKey("OFF")) ||
                                      _AttributeForLanguage.CurrentUser.GetLanguageTextFromKey(item.To).Equals(_AttributeForLanguage.CurrentUser.GetLanguageTextFromKey("OFF"))) ? false : true;
                    item.IsOffline = itemIsOff;
                    //}

                    if (/*!item.From.ToLower().Equals("off") && !item.To.ToLower().Equals("off")*/ item.IsOffline)
                    {
                        item.FromTime = Convert.ToDateTime(item.From);
                        item.ToTime   = Convert.ToDateTime(item.To);
                        if (item.FromTime.TimeOfDay > item.ToTime.TimeOfDay)
                        {
                            ModelState.AddModelError("ListBusinessHour", CurrentUser.GetLanguageTextFromKey("From time must be less than To time"));
                            break;
                        }
                    }
                    item.IsOffline = !item.IsOffline;
                }
                if (!ModelState.IsValid)
                {
                    model = GetDetail(model.ID);

                    // Get list Countries
                    // Updated 08292017
                    List <CountryApiModels> lstCountries = CommonHelper.GetListCountry();
                    foreach (var country in lstCountries)
                    {
                        model.ListCountries.Add(new SelectListItem
                        {
                            Value    = country.Name,
                            Text     = country.Name,
                            Selected = country.Name.Equals(countryChoose) ? true : false
                        });
                    }

                    // Updated 08312017
                    model.ListTimezones = GetTimezonesOfCountry(lstCountries, countryChoose, timeZoneChoose);

                    Response.StatusCode = (int)HttpStatusCode.BadRequest;
                    return(PartialView("_Edit", model));
                }
                var tmp = model.PictureByte;
                model.PictureByte = null;
                var result = _factory.InsertOrUpdateStore(model);
                if (result)
                {
                    if (!string.IsNullOrEmpty(model.ImageURL) && tmp != null)
                    {
                        FTP.Upload(model.ImageURL, tmp);
                    }
                    return(RedirectToAction("Index"));
                }
                else
                {
                    // Get list Countries
                    // Updated 08292017
                    List <CountryApiModels> lstCountries = CommonHelper.GetListCountry();
                    foreach (var country in lstCountries)
                    {
                        model.ListCountries.Add(new SelectListItem
                        {
                            Value    = country.Name,
                            Text     = country.Name,
                            Selected = country.Name.Equals(countryChoose) ? true : false
                        });
                    }

                    // Updated 08312017
                    model.ListTimezones = GetTimezonesOfCountry(lstCountries, countryChoose, timeZoneChoose);

                    return(PartialView("_Edit", model));
                }
            }
            catch (FormatException fEx)
            {
                _logger.Error("StoreInformations_Edit: " + fEx.Message);
                ModelState.AddModelError("name", fEx.Message);
                model = GetDetail(model.ID);

                // Get list Countries
                // Updated 08292017
                List <CountryApiModels> lstCountries = CommonHelper.GetListCountry();
                foreach (var country in lstCountries)
                {
                    model.ListCountries.Add(new SelectListItem
                    {
                        Value    = country.Name,
                        Text     = country.Name,
                        Selected = country.Name.Equals(model.Country) ? true : false
                    });
                }

                // Updated 08312017
                model.ListTimezones = GetTimezonesOfCountry(lstCountries, model.Country, model.TimeZone);

                Response.StatusCode = (int)HttpStatusCode.BadRequest;
                return(PartialView("_Edit", model));
            }
            catch (Exception ex)
            {
                _logger.Error("StoreInformations_Edit: " + ex);
                ModelState.AddModelError("name", ex.Message);
                model = GetDetail(model.ID);

                // Get list Countries
                // Updated 08292017
                List <CountryApiModels> lstCountries = CommonHelper.GetListCountry();
                foreach (var country in lstCountries)
                {
                    model.ListCountries.Add(new SelectListItem
                    {
                        Value    = country.Name,
                        Text     = country.Name,
                        Selected = country.Name.Equals(model.Country) ? true : false
                    });
                }

                // Updated 08312017
                model.ListTimezones = GetTimezonesOfCountry(lstCountries, model.Country, model.TimeZone);

                Response.StatusCode = (int)HttpStatusCode.BadRequest;
                return(PartialView("_Edit", model));
            }
        }
예제 #7
0
        public new PartialViewResult View(string id)
        {
            SStoreModels model = GetDetail(id);

            return(PartialView("_View", model));
        }
예제 #8
0
        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);
            }
        }