public void NUnit_Contract_Domain_Add() { Cat_LeaveDayTypeServices service = new Cat_LeaveDayTypeServices(); bool result = true; int countSC = 0; for (int i = 1; i <= 10; i++) { var model = new Cat_LeaveDayType { Code = "Add Code " + i, LeaveDayTypeName = "Loai Ngay Nghi "+i, PaidRate = 1, SocialRate = 2 }; result = service.AddCatLeaveDayType(model); NUnit.Framework.Assert.IsTrue(result); if (result == true) { countSC += 1; Console.WriteLine("Process Success >>> Create >>> " + model.Id + " | " + model.Code + " | " + model.LeaveDayTypeName + " | " + model.PaidRate + " | " + model.SocialRate ); } } Console.WriteLine("Total success record: " + countSC); }
/// <summary> /// Tìm kiếm bản ghi có theo tham số id /// </summary> /// <param name="id"></param> /// <returns></returns> public Cat_LeaveDayType GetByIdCatLeaveDayType(int id) { using (var context = new VnrAttendanceDataContext()) { IUnitOfWork unitOfWork = (IUnitOfWork)(new UnitOfWork(context)); Cat_LeaveDayTypeRepository repo = new Cat_LeaveDayTypeRepository(unitOfWork); Cat_LeaveDayType catLeaveDayType = new Cat_LeaveDayType(); catLeaveDayType = repo.GetById(id); if (catLeaveDayType.IsDelete == true) catLeaveDayType = null; return catLeaveDayType; } }
public void NUnit_Contract_Domain_GetById() { Cat_LeaveDayTypeServices service = new Cat_LeaveDayTypeServices(); var model = new Cat_LeaveDayType { Id = 3 }; var result = service.GetByIdCatLeaveDayType(model.Id) as Cat_LeaveDayType; NUnit.Framework.Assert.IsNotNull(result); Console.Write("SearchResult: " + result.Id + " | " + result.Code + " | " + result.LeaveDayTypeName + " | " + result.PaidRate + " | " + result.SocialRate ); }
public void NUnit_Contract_Domain_Remove() { Cat_LeaveDayTypeServices service = new Cat_LeaveDayTypeServices(); int rs = 0; var model = new Cat_LeaveDayType { Id = 3 }; bool result = service.DeleteCatLeaveDayType(model.Id); NUnit.Framework.Assert.IsTrue(result); if (result == true) { rs += 1; Console.WriteLine("Process Success >>> Remove >>> " + model.Id); } }
/// <summary> /// Tìm kiếm bản ghi có theo tham số id /// </summary> /// <param name="id"></param> /// <returns></returns> public Cat_LeaveDayType GetByIdCatLeaveDayType(int id) { using (var context = new VnrAttendanceDataContext()) { IUnitOfWork unitOfWork = (IUnitOfWork)(new UnitOfWork(context)); Cat_LeaveDayTypeRepository repo = new Cat_LeaveDayTypeRepository(unitOfWork); Cat_LeaveDayType catLeaveDayType = new Cat_LeaveDayType(); catLeaveDayType = repo.GetById(id); if (catLeaveDayType.IsDelete == true) { catLeaveDayType = null; } return(catLeaveDayType); } }
/// <summary> /// Thêm bản ghi mới /// </summary> /// <param name="catLeaveDayType"></param> /// <returns></returns> public bool AddCatLeaveDayType(Cat_LeaveDayType catLeaveDayType) { using (var context = new VnrAttendanceDataContext()) { IUnitOfWork unitOfWork = (IUnitOfWork)(new UnitOfWork(context)); Cat_LeaveDayTypeRepository repo = new Cat_LeaveDayTypeRepository(unitOfWork); try { repo.Add(catLeaveDayType); repo.SaveChanges(); return true; } catch { return false; } } }
/// <summary> /// Update bản ghi /// </summary> /// <param name="catLeaveDayType"></param> /// <returns></returns> public bool UpdateCatLeaveDayType(Cat_LeaveDayType catLeaveDayType) { using (var context = new VnrAttendanceDataContext()) { IUnitOfWork unitOfWork = (IUnitOfWork)(new UnitOfWork(context)); Cat_LeaveDayTypeRepository repo = new Cat_LeaveDayTypeRepository(unitOfWork); try { repo.Edit(catLeaveDayType); repo.SaveChanges(); return(true); } catch { return(false); } } }
/// <summary> /// Update thuộc tính IsDelete là true /// </summary> /// <param name="catLeaveDayTypeId"></param> /// <returns></returns> public bool DeleteCatLeaveDayType(int catLeaveDayTypeId) { using (var context = new VnrAttendanceDataContext()) { IUnitOfWork unitOfWork = (IUnitOfWork)(new UnitOfWork(context)); Cat_LeaveDayTypeRepository repo = new Cat_LeaveDayTypeRepository(unitOfWork); Cat_LeaveDayType catLeaveDayType = new Cat_LeaveDayType(); catLeaveDayType = repo.GetById(catLeaveDayTypeId); try { repo.Remove(catLeaveDayType); repo.SaveChanges(); return(true); } catch { return(false); } } }
public void NUnit_Contract_Domain_Edit() { Cat_LeaveDayTypeServices service = new Cat_LeaveDayTypeServices(); var model = new Cat_LeaveDayType { Id = 5, Code = "Update Code ", LeaveDayTypeName = "Update Loai Ngay Nghi ", PaidRate = 3, SocialRate = 4 }; bool result = service.UpdateCatLeaveDayType(model); NUnit.Framework.Assert.IsTrue(result); if (result == true) { Console.WriteLine("Process Success >>> Update >>> " + model.Id + " | " + model.Code + " | " + model.LeaveDayTypeName + " | " + model.PaidRate + " | " + model.SocialRate ); } }
/// <summary> /// Update thuộc tính IsDelete là true /// </summary> /// <param name="catLeaveDayTypeId"></param> /// <returns></returns> public bool DeleteCatLeaveDayType(int catLeaveDayTypeId) { using (var context = new VnrAttendanceDataContext()) { IUnitOfWork unitOfWork = (IUnitOfWork)(new UnitOfWork(context)); Cat_LeaveDayTypeRepository repo = new Cat_LeaveDayTypeRepository(unitOfWork); Cat_LeaveDayType catLeaveDayType = new Cat_LeaveDayType(); catLeaveDayType = repo.GetById(catLeaveDayTypeId); try { repo.Remove(catLeaveDayType); repo.SaveChanges(); return true; } catch { return false; } } }