public string UpdateFlat(FlatModel flat) { Mapper.CreateMap <FlatModel, Flat>().ForMember(dest => dest.FlatPLCs, sec => sec.Ignore()); Flat fl = Mapper.Map <FlatModel, Flat>(flat); int i = fservice.EditFlat(fl); FlatPLCService fpservice = new FlatPLCService(); var model = fpservice.GetFlatPLCListByFlatID(fl.FlatID); foreach (var ft in model) { FlatPLC md = new FlatPLC(); md.FlatPLCID = ft.FlatPLCID; int ii = fpservice.DeleteFlatPLC(md); } foreach (string st in flat.FlatPLCs) { if (st != "0") { FlatPLC fpm = new FlatPLC(); fpm.FlatID = fl.FlatID; fpm.PLCID = Convert.ToInt32(st); int ii = fpservice.AddFlatPLC(fpm); } } return(i.ToString()); }
public string GetFlatPCLHtml(int flatid) { string html = ""; PLCService ps = new PLCService(); FlatPLCService fservice = new FlatPLCService(); var model = ps.GetAllPLC(); html += "<div id='panelPLC'>"; foreach (var pm in model) { bool bl = fservice.IsPLCinFlat(pm.PLCID, flatid); if (bl == true) { string id = pm.PLCID.ToString(); html += @"<label class='checkbox'><input type='checkbox' value='" + pm.PLCID + "' name='" + pm.PLCName + "' id='" + id + "' checked='checked'><i></i> " + pm.PLCName + "</label>"; } else { string id = pm.PLCID.ToString(); html += @"<label class='checkbox'><input type='checkbox' value='" + pm.PLCID + "' name='" + pm.PLCName + "' id='" + id + "'><i></i> " + pm.PLCName + "</label>"; } } html += "</div></div>"; return(html); }
public string SaveFat(FlatModel flat) { Mapper.CreateMap <FlatModel, Flat>().ForMember(dsd => dsd.FlatPLCs, df => df.Ignore()); Flat fl = Mapper.Map <FlatModel, Flat>(flat); fl.CrBy = User.Identity.Name; fl.CrDate = DateTime.Now; int i = fservice.AddNewFlat(fl); FlatPLCService fpservice = new FlatPLCService(); foreach (string st in flat.FlatPLCs) { if (st != "0") { FlatPLC fpm = new FlatPLC(); fpm.FlatID = fl.FlatID; fpm.PLCID = Convert.ToInt32(st); int ii = fpservice.AddFlatPLC(fpm); } } return(i.ToString()); }