public DMToaSoanModel(DMToaSoan DMToaSoan) { this.Id = DMToaSoan.Id; this.MaToaSoan = DMToaSoan.MaToaSoan; this.TenToaSoan = DMToaSoan.TenToaSoan; this.DiaChi = DMToaSoan.DiaChi; this.SoDienThoai = DMToaSoan.SoDienThoai; this.Email = DMToaSoan.Email; this.Web = DMToaSoan.Web; this.MaSoThue = DMToaSoan.MaSoThue; this.TaiKhoan = DMToaSoan.TaiKhoan; this.TongBienTap = DMToaSoan.TongBienTap; this.NguoiDaiDien = DMToaSoan.NguoiDaiDien; this.CoQuanChuQuan = DMToaSoan.CoQuanChuQuan; this.Status = DMToaSoan.Status; this.KieuToaSoan = DMToaSoan.KieuToaSoan; this.NganHang = DMToaSoan.NganHang; if (this.KieuToaSoan == (int)Enums.KieuToaSoan.DiaPhuong) { this.NameKieuToaSoan = "Tòa soạn Địa Phương"; } else if (this.KieuToaSoan == (int)Enums.KieuToaSoan.TrungUong) { this.NameKieuToaSoan = "Tòa soạn Trung Ương"; } else this.NameKieuToaSoan = ""; this.CreateBy = DMToaSoan.CreateBy; this.CreateDate = DMToaSoan.CreateDate; this.ModifyBy = DMToaSoan.ModifyBy; this.ModifyDate = DMToaSoan.ModifyDate; }
/*** * function: Delete() * param : DMToaSoan * result: int * author: vietvb * Delete dữ liệu, trả ra int * */ public int Delete(DMToaSoan DMToaSoan) { //DMToaSoan DMToaSoan = db.DMToaSoans.Find(id); //db.DMToaSoans.Remove(DMToaSoan); //return db.SaveChanges(); //reset status for delete DMToaSoan.Status = (int)Enums.RecordStatusCode.delete; db.Entry(DMToaSoan).State = EntityState.Modified; return db.SaveChanges(); }
/*** * function: Add() * param : DMToaSoan * result: int * author: vietvb * Thêm dữ liệu, trả ra id * */ public int Add(DMToaSoan DMToaSoan) { DMToaSoan.Status = (int)Enums.RecordStatusCode.active; db.DMToaSoans.Add(DMToaSoan); return db.SaveChanges(); }
private void CopyData(DMToaSoan old, DMToaSoan newTS) { old.MaToaSoan = newTS.MaToaSoan; old.TenToaSoan = newTS.TenToaSoan; old.DiaChi = newTS.DiaChi; old.SoDienThoai = newTS.SoDienThoai; old.Email = newTS.Email; old.Web = newTS.Web; old.MaSoThue = newTS.MaSoThue; old.TaiKhoan = newTS.TaiKhoan; old.TongBienTap = newTS.TongBienTap; old.NguoiDaiDien = newTS.NguoiDaiDien; old.CoQuanChuQuan = newTS.CoQuanChuQuan; old.KieuToaSoan = newTS.KieuToaSoan; old.NganHang = newTS.NganHang; }
/*** * function: Update() * param : DMToaSoan * result: int * author: vietvb * Update dữ liệu, trả ra id * */ public int Update(DMToaSoan dmToaSoan) { dmToaSoan.Status = (int)Enums.RecordStatusCode.active; //get old data DMToaSoan Old = db.DMToaSoans.Find(dmToaSoan.Id); CopyData(Old, dmToaSoan); Old.ModifyBy = dmToaSoan.ModifyBy; Old.ModifyDate = dmToaSoan.ModifyDate; //edit //db.Entry(DMToaSoan).State = EntityState.Modified; return db.SaveChanges(); }
public DMToaSoan toDMToaSoan() { DMToaSoan result = new DMToaSoan(); result.Id = string.IsNullOrEmpty(this.Id) ? Guid.NewGuid().ToString() : this.Id; result.MaToaSoan = this.MaToaSoan; result.TenToaSoan = this.TenToaSoan; result.DiaChi = this.DiaChi; result.SoDienThoai = this.SoDienThoai; result.Email = this.Email; result.Web = this.Web; result.MaSoThue = this.MaSoThue; result.TaiKhoan = this.TaiKhoan; result.TongBienTap = this.TongBienTap; result.NguoiDaiDien = this.NguoiDaiDien; result.CoQuanChuQuan = this.CoQuanChuQuan; result.Status = this.Status; result.KieuToaSoan = this.KieuToaSoan; result.NganHang = this.NganHang; result.CreateBy = this.CreateBy; result.CreateDate = this.CreateDate; result.ModifyBy = this.ModifyBy; result.ModifyDate = this.ModifyDate; return result; }