Пример #1
0
        public ActionResult Create(CategoryModel ins, string mdlListDetail)
        {
            List <SensorDetailModel> ListDetailSensor;
            JavaScriptSerializer     jss = new JavaScriptSerializer();

            ListDetailSensor = jss.Deserialize <List <SensorDetailModel> >(mdlListDetail);
            string ret = "";
            string res = "";

            ins.UserEntry = Session["IDUser"].ToString();

            // ins.SiteCode = Session["IDSite"].ToString();
            if (ModelState.IsValid)
            {
                try
                {
                    // ret = EMC.EmployeeInsert(ins, IsActive);
                    ret = cc.CategoryInsertorupdate(ins);
                    if (ret.Contains("ERR|"))
                    {
                        res = ret;
                    }
                    else
                    {
                        var hsl = "";
                        foreach (var sensor in ListDetailSensor)
                        {
                            hsl = cc.createoreditsensorparamdetail(sensor.id, ret == null?ins.CategoryID:ret, sensor.valuelower, sensor.valueupper, Session["IDUser"].ToString());
                            if (hsl.Contains("Err|"))
                            {
                                res = hsl;
                            }
                            else
                            {
                                res = "1";
                            }
                        }
                    }
                }
                catch (Exception err)
                {
                    ret = err.Message;
                    return(Json(new { result = ret }));
                }
            }
            return(Json(new { result = res }));
        }