public int EditNguoiDung(NguoiDungViewModel model) { try { int? IDHInhAnh = db.Tb_NguoiDung.Where(x => x.ID == model.ID).First().IDHInhAnh; Tb_HinhAnh tb_HinhAnh = db.Tb_HinhAnh.Find(IDHInhAnh); if (model.DuongDanHInhAnh != null) { tb_HinhAnh.DuongDan = model.DuongDanHInhAnh; db.SaveChanges(); } Tb_NguoiDung tb_NguoiDung = db.Tb_NguoiDung.Find(model.ID); tb_NguoiDung.DiaChi = model.DiaChi; tb_NguoiDung.Email = model.Email; tb_NguoiDung.GioiTinh = model.GioiTinh; if (model.MatKhau.Trim().Length > 0) { tb_NguoiDung.MatKhau = MaHoaMD5(model.MatKhau); } tb_NguoiDung.NgaySinh = model.NgaySinh; tb_NguoiDung.SoDienThoai = model.SoDienThoai; tb_NguoiDung.HoTen = model.HoTen; db.SaveChanges(); return(1); } catch { return(0); } }
public int AddNguoiDung(NguoiDungViewModel model) { try { Tb_HinhAnh tb_HinhAnh = new Tb_HinhAnh(); tb_HinhAnh.DuongDan = model.DuongDanHInhAnh; db.Tb_HinhAnh.Add(tb_HinhAnh); db.SaveChanges(); db.Tb_NguoiDung.Add(new Tb_NguoiDung() { DiaChi = model.DiaChi, Email = model.Email, GioiTinh = model.GioiTinh, MatKhau = MaHoaMD5(model.MatKhau), HoTen = model.HoTen, LaQuanTriVienCapCao = model.LaQuanTriVienCapCao, NgaySinh = model.NgaySinh, SoDienThoai = model.SoDienThoai, IDHInhAnh = tb_HinhAnh.ID, }); db.SaveChanges(); return(1); } catch { return(0); } }
public int EditTinTuc(TinTucViewModel model) { try { int? IDHInhAnh = db.Tb_TinTuc.Where(x => x.ID == model.ID).First().IDHInhAnh; Tb_HinhAnh tb_HinhAnh = db.Tb_HinhAnh.Find(IDHInhAnh); if (model.DuongDanHinhAnh != null) { tb_HinhAnh.DuongDan = model.DuongDanHinhAnh; db.SaveChanges(); } Tb_TinTuc tb_TinTuc = db.Tb_TinTuc.Find(model.ID); tb_TinTuc.TieuDe = model.TieuDe; tb_TinTuc.NoiDung = model.NoiDung; tb_TinTuc.DanNhap = model.DanNhap; db.SaveChanges(); return(1); } catch { return(0); } }
public int EditThucVat(ThucVatViewModel model) { try { int? IDHInhAnh = db.Tb_ThucVat.Where(x => x.ID == model.ID).First().IDHInhAnh; Tb_HinhAnh tb_HinhAnh = db.Tb_HinhAnh.Find(IDHInhAnh); if (model.DuongDanHInhAnh != null) { tb_HinhAnh.DuongDan = model.DuongDanHInhAnh; db.SaveChanges(); } Tb_ThucVat tb_ThucVat = db.Tb_ThucVat.Find(model.ID); tb_ThucVat.TenLaTinh = model.TenLaTinh; tb_ThucVat.TenVietNam = model.TenVietNam; tb_ThucVat.MoTa = model.MoTa; tb_ThucVat.IDGiaTriKinhTe = model.IDGiaTriKinhTe; tb_ThucVat.IDKhaNangSinhTruong = model.IDKhaNangSinhTruong; tb_ThucVat.IDKhaNangTaiSinh = model.IDKhaNangTaiSinh; tb_ThucVat.IDHo = model.IDHo; tb_ThucVat.DoDayLa = model.DoDayLa; tb_ThucVat.DoDayVo = model.DoDayVo; tb_ThucVat.LuongNuocTrongLa = model.LuongNuocTrongLa; tb_ThucVat.LuongNuocTrongVo = model.LuongNuocTrongVo; tb_ThucVat.LuongTroThoTrongLa = model.LuongTroThoTrongLa; tb_ThucVat.LuongTroThoTrongVo = model.LuongTroThoTrongVo; tb_ThucVat.ThoiGianChayTrenLa = model.ThoiGianChayTrenLa; tb_ThucVat.ThoiGianChayTrenVo = model.ThoiGianChayTrenVo; db.SaveChanges(); return(1); } catch { return(0); } }
public int AddThucVat(ThucVatViewModel model) { try { Tb_HinhAnh tb_HinhAnh = new Tb_HinhAnh(); tb_HinhAnh.DuongDan = model.DuongDanHInhAnh; db.Tb_HinhAnh.Add(tb_HinhAnh); db.SaveChanges(); db.Tb_ThucVat.Add(new Tb_ThucVat() { TenLaTinh = model.TenLaTinh, TenVietNam = model.TenVietNam, MoTa = model.MoTa, IDGiaTriKinhTe = model.IDGiaTriKinhTe, IDKhaNangSinhTruong = model.IDKhaNangSinhTruong, IDKhaNangTaiSinh = model.IDKhaNangTaiSinh, IDHInhAnh = tb_HinhAnh.ID, IDHo = model.IDHo, DoDayLa = model.DoDayLa, DoDayVo = model.DoDayVo, LuongNuocTrongLa = model.LuongNuocTrongLa, LuongNuocTrongVo = model.LuongNuocTrongVo, LuongTroThoTrongLa = model.LuongTroThoTrongLa, LuongTroThoTrongVo = model.LuongTroThoTrongVo, ThoiGianChayTrenLa = model.ThoiGianChayTrenLa, ThoiGianChayTrenVo = model.ThoiGianChayTrenVo }); db.SaveChanges(); return(1); } catch { return(0); } }
public int AddTinTuc(TinTucViewModel model) { try { Tb_HinhAnh tb_HinhAnh = new Tb_HinhAnh(); tb_HinhAnh.DuongDan = model.DuongDanHinhAnh; db.Tb_HinhAnh.Add(tb_HinhAnh); db.SaveChanges(); db.Tb_TinTuc.Add(new Tb_TinTuc() { TieuDe = model.TieuDe, DanNhap = model.DanNhap, NoiDung = model.NoiDung, IDHInhAnh = tb_HinhAnh.ID, }); db.SaveChanges(); return(1); } catch { return(0); } }