Exemplo n.º 1
0
        public ActionResult AddCatalogInfoData(FormCollection submit)
        {
            _catalogInfoSrv.UserVM = UserVM;
            int custAutoID = Convert.ToInt32(submit["custAutoID"]);
            CreateCatalogInfoModel      CreateCatInfoModel = new CreateCatalogInfoModel();
            Dictionary <string, string> dctSelectedValues  = new Dictionary <string, string>();

            //Adding the Selecting Items and text values to teh dictionary.
            string catalogInsertStatus = string.Empty;

            foreach (string key in submit)
            {
                if (key == "CatalogSaveStaus")
                {
                    catalogInsertStatus = "true";
                }
                else
                {
                    if (key != "custAutoID" && key != "txtbox" && key != "quoteID")
                    {
                        if (submit.GetValues(key).ToList().FirstOrDefault() != "false" && submit.GetValues(key).ToList().FirstOrDefault() != "0" && submit.GetValues(key).ToList().FirstOrDefault() != string.Empty)
                        {
                            dctSelectedValues.Add(key, submit.GetValues(key).ToList().FirstOrDefault());
                        }
                    }
                }
            }
            // Creating Customer Catalog Information with the selected Values
            _catalogInfoSrv.CreateCatalogInfo(dctSelectedValues, custAutoID);
            ////Loading the values and showing the values with the selected Data
            //CatalogInfoViewModel catInfovm = _catalogInfoSrv.getCatalogInfoValues(custUserID);
            return(RedirectToAction("ViewCatalogInfo", "CatalogInfo", new { custAutoID = custAutoID, catalogInsertStatus = catalogInsertStatus, quoteid = UserVM.CurrentQuoteID }));
        }
        public CreateCatalogInfoModel CreateCatalogInfo(Dictionary <string, string> dctSelectionValues, int custAutoID)
        {
            List <CreateCatalogInfoModel> lstcreatecatInfoModel        = new List <CreateCatalogInfoModel>();
            List <CreateCatalogInfoModel> lstcreateProtectorInfoModel  = new List <CreateCatalogInfoModel>();
            List <CreateCatalogInfoModel> lstcreateShelfReadyInfoModel = new List <CreateCatalogInfoModel>();

            foreach (string key in dctSelectionValues.Keys)
            {
                CreateCatalogInfoModel createcatInfoNewModel = null;
                if (!key.Contains("-"))
                {
                    createcatInfoNewModel            = new CreateCatalogInfoModel();
                    createcatInfoNewModel.CustUserID = custAutoID;
                    int catalogSubjectOptID = Convert.ToInt32(key);
                    CatalogSubjectOptionValue catalogSubOptionvalue = _Context.CatalogSubjectOptionValue.GetSingle(e => e.CatalogSubjectOptionID == catalogSubjectOptID);
                    if (catalogSubOptionvalue.CatalogSubjectOption.CatalogSubjectID == 16)
                    {
                        createcatInfoNewModel.CatalogSubjectOptionValueID = catalogSubOptionvalue.CatalogSubjectOptionValueID;
                    }
                    else
                    {
                        createcatInfoNewModel.CatalogSubjectOptionValueID = catalogSubOptionvalue.CatalogSubjectOptionValueID;
                        if (catalogSubOptionvalue.CatalogSubjectOption.ColumnType == (int)CatalogColumnTypeEnum.ComboBox)
                        {
                            createcatInfoNewModel.CatalogSubjectOptionValueID = Convert.ToInt32(dctSelectionValues[key]);
                        }
                    }
                    if (catalogSubOptionvalue.CatalogSubjectOption.ColumnType == (int)CatalogColumnTypeEnum.TextBox ||
                        catalogSubOptionvalue.CatalogSubjectOption.ColumnType == (int)CatalogColumnTypeEnum.TextArea)
                    {
                        if (dctSelectionValues[key] != string.Empty && dctSelectionValues[key] != "true")
                        {
                            createcatInfoNewModel.Comments = dctSelectionValues[key];
                        }
                    }
                }
                else
                {
                    createcatInfoNewModel            = new CreateCatalogInfoModel();
                    createcatInfoNewModel.CustUserID = custAutoID;
                    if (key.Contains("P"))
                    {
                        //for protector
                        int catalogProtectorID = Convert.ToInt32(key.Split('-')[1]);
                        CatalogSubjectOptionProtectorValue catSubjOptProtectorValueInfo = _Context.CatalogSubjectOptionProtectorValue.GetSingle(e => e.CSOProtectorID == catalogProtectorID);
                        createcatInfoNewModel.CatalogSubjectOptionValueID = catSubjOptProtectorValueInfo.CatalogSubjectOptionValue.CatalogSubjectOptionValueID;
                        createcatInfoNewModel.CCProtectorValueID          = catSubjOptProtectorValueInfo.CSOProtectorvalueID;
                        lstcreateProtectorInfoModel.Add(createcatInfoNewModel);
                    }
                    else if (key.Contains("S"))
                    {
                        //for Shelf Ready
                        int catalogShelfReadyID = Convert.ToInt32(key.Split('-')[1]);
                        CatalogSubjectOptionShelfReadyValue catSubjOptShelfReadyValueInfo = _Context.CatalogSubjectOptionShelfReadyValue.GetSingle(e => e.CSOShelfReadyID == catalogShelfReadyID);
                        createcatInfoNewModel.CatalogSubjectOptionValueID = catSubjOptShelfReadyValueInfo.CatalogSubjectOptionValue.CatalogSubjectOptionValueID;
                        createcatInfoNewModel.CCShelfReadyValueID         = catSubjOptShelfReadyValueInfo.CSOShelfReadyvalueID;
                        lstcreateShelfReadyInfoModel.Add(createcatInfoNewModel);
                    }
                    else if (key.Contains("-B"))
                    {
                        //for Bottom Label Placement
                        int catalogSubjectOptID = Convert.ToInt32(key.Split('-')[0]);
                        CatalogSubjectOptionValue catalogSubOptionvalue = _Context.CatalogSubjectOptionValue.GetSingle(e => e.CatalogSubjectOptionID == catalogSubjectOptID && e.CatalogSubjectOptionValue1 == "Other");
                        lstcreatecatInfoModel.Where(e => e.CatalogSubjectOptionValueID == catalogSubOptionvalue.CatalogSubjectOptionValueID).FirstOrDefault().Comments = dctSelectionValues[key];
                    }
                    else
                    {
                        //for checkboxes storing multple values.
                        int catalogSubjectOptionValueID = Convert.ToInt32(key.Split('-')[1]);
                        createcatInfoNewModel.CatalogSubjectOptionValueID = catalogSubjectOptionValueID;
                        lstcreatecatInfoModel.Add(createcatInfoNewModel);
                    }
                }
                if (createcatInfoNewModel != null)
                {
                    if (!key.Contains("-"))
                    {
                        lstcreatecatInfoModel.Add(createcatInfoNewModel);
                    }
                }
            }
            CheckingandInsertorUpdateCatalogData(lstcreatecatInfoModel, lstcreateProtectorInfoModel, lstcreateShelfReadyInfoModel, custAutoID);
            return(null);
        }