public MstBillOfLading UpdateObject(MstBillOfLading cost)
 {
     if (!isValid(_validator.VUpdateObject(cost, this)))
     {
         cost = _repository.UpdateObject(cost);
     }
     return(cost);
 }
 public MstBillOfLading VAbbrevation(MstBillOfLading mstbilloflading, IMstBillOfLadingService _mstbillofladingService)
 {
     if (String.IsNullOrEmpty(mstbilloflading.Abbrevation) || mstbilloflading.Abbrevation.Trim() == "")
     {
         mstbilloflading.Errors.Add("Abbrevation", "Tidak boleh kosong");
     }
     return(mstbilloflading);
 }
 public MstBillOfLading CreateObject(MstBillOfLading cost)
 {
     cost.Errors = new Dictionary <String, String>();
     if (!isValid(_validator.VCreateObject(cost, this)))
     {
         cost.MasterCode = _repository.GetLastMasterCode(cost.OfficeId) + 1;
         cost            = _repository.CreateObject(cost);
     }
     return(cost);
 }
 public MstBillOfLading VName(MstBillOfLading mstbilloflading, IMstBillOfLadingService _mstbillofladingService)
 {
     if (String.IsNullOrEmpty(mstbilloflading.Name) || mstbilloflading.Name.Trim() == "")
     {
         mstbilloflading.Errors.Add("Name", "Tidak boleh kosong");
     }
     else if (_mstbillofladingService.IsNameDuplicated(mstbilloflading))
     {
         mstbilloflading.Errors.Add("Name", "Tidak boleh diduplikasi");
     }
     return(mstbilloflading);
 }
        public MstBillOfLading VObject(MstBillOfLading mstbilloflading, IMstBillOfLadingService _mstbillofladingService)
        {
            MstBillOfLading oldmstbilloflading = _mstbillofladingService.GetObjectById(mstbilloflading.Id);

            if (oldmstbilloflading == null)
            {
                mstbilloflading.Errors.Add("Generic", "Invalid Data For Update");
            }
            else if (!VOffice(mstbilloflading.OfficeId, oldmstbilloflading.OfficeId))
            {
                mstbilloflading.Errors.Add("Generic", "Invalid Data For Update");
            }
            return(mstbilloflading);
        }
 public MstBillOfLading VCreateObject(MstBillOfLading mstbilloflading, IMstBillOfLadingService _mstbillofladingService)
 {
     VName(mstbilloflading, _mstbillofladingService);
     if (!isValid(mstbilloflading))
     {
         return(mstbilloflading);
     }
     VAbbrevation(mstbilloflading, _mstbillofladingService);
     if (!isValid(mstbilloflading))
     {
         return(mstbilloflading);
     }
     return(mstbilloflading);
 }
        public bool isValid(MstBillOfLading obj)
        {
            bool isValid = !obj.Errors.Any();

            return(isValid);
        }
 public bool IsNameDuplicated(MstBillOfLading cost)
 {
     return(_repository.IsNameDuplicated(cost));
 }
 public MstBillOfLading SoftDeleteObject(MstBillOfLading cost)
 {
     cost = _repository.SoftDeleteObject(cost);
     return(cost);
 }