public ActionResult AssignAdOptionsToStore(AllowedStoreOptionModel model)
        {
            TransactionMessage TransMessage = new TransactionMessage();

            TransMessage.Status = MessageStatus.Error;
            try
            {
                if (ModelState.IsValid)
                {
                    model = _storeoption.Save(model);
                    if (model.TransMessage.Status == MessageStatus.Success)
                    {
                        SuccessNotification(model.TransMessage.Message);
                    }
                }
                else
                {
                    TransMessage.Message = utilityHelper.ReadGlobalMessage("ManageStoreOption", "ErrorMessage");
                }
            }
            catch (Exception ex)
            {
                // write exception log
                EventLogHandler.WriteLog(ex);
            }
            return(Json(model.TransMessage, JsonRequestBehavior.DenyGet));
        }
        public ActionResult AllowAdOptions()
        {
            AllowedStoreOptionModel model = new AllowedStoreOptionModel();

            ViewBag.OptionList = _common.GetAdOptionList();
            return(View(model));
        }
        public ActionResult StoreList(string id)
        {
            int adOptionId = 0;

            if (!string.IsNullOrEmpty(id) && id.IsNumber())
            {
                adOptionId = Convert.ToInt32(id);
            }
            AllowedStoreOptionModel model = new AllowedStoreOptionModel();

            model.Detail = _storeoption.GetList(adOptionId);
            return(View(model));
        }
        // Save all store with a single AdOption
        public AllowedStoreOptionModel Save(AllowedStoreOptionModel model)
        {
            model.TransMessage        = new TransactionMessage();
            model.TransMessage.Status = MessageStatus.Error;

            try
            {
                if (model.AdOptionID > 0 && model.Detail != null && model.Detail.Count() > 0)
                {
                    #region Delete Existing Entry
                    var dbList = UnitofWork.RepoAllowedStoreOption.Where(x => x.AdOptionID == model.AdOptionID).ToList();
                    foreach (var item in dbList)
                    {
                        UnitofWork.RepoAllowedStoreOption.Delete(item);
                    }
                    UnitofWork.Commit();
                    #endregion

                    foreach (var item in model.Detail)
                    {
                        if (item.IsSelect && item.StoreID > 0)
                        {
                            UnitofWork.RepoAllowedStoreOption.Add(new AllowedStoreOption()
                            {
                                AdOptionID = model.AdOptionID,
                                StoreID    = item.StoreID,
                            });
                        }
                    }
                    UnitofWork.Commit();
                    model.TransMessage.Message = utilityHelper.ReadGlobalMessage("ManageStoreOption", "Save");
                    model.TransMessage.Status  = MessageStatus.Success;
                }
            }
            catch (Exception ex)
            {
                EventLogHandler.WriteLog(ex);
            }
            return(model);
        }