Exemplo n.º 1
0
 public void UpdateVendor(VendorDTO vendorDTO, DateTime dateStamp)
 {
     if (vendorDTO == null)
     {
         throw new ArgumentNullException("Vendor model is null.");
     }
     tblM_Vendor vendor = vendorFactory.CreateFromDbAndUpdateFromDTO(vendorDTO, dateStamp);
 }
Exemplo n.º 2
0
        public tblM_Vendor AddVendor(VendorDTO vendorDTO, DateTime dateStamp)
        {
            if (vendorDTO == null)
            {
                throw new ArgumentNullException("Vendor model is null.");
            }
            tblM_Vendor vendor = vendorFactory.CreateFromDTO(vendorDTO, dateStamp);

            return(Db.tblM_Vendor.Add(vendor));
        }
Exemplo n.º 3
0
        public tblM_Vendor CreateFromDTO(VendorDTO vendorDTO, DateTime dateStamp)
        {
            if (vendorDTO == null)
            {
                throw new ArgumentNullException("Vendor model is null.");
            }
            vendorDTO.Status_FK   = (int)RecordStatus.Active;
            vendorDTO.CreatedBy   = User.Username;
            vendorDTO.CreatedDate = dateStamp;
            vendorDTO.UpdatedBy   = User.Username;
            vendorDTO.UpdatedDate = dateStamp;
            tblM_Vendor vendor = vendorDTO.ToObject <tblM_Vendor>();

            return(vendor);
        }
Exemplo n.º 4
0
        public tblM_Vendor CreateFromDbAndUpdateFromDTO(VendorDTO vendorDTO, DateTime dateStamp)
        {
            tblM_Vendor vendor;

            if (vendorDTO == null)
            {
                throw new ArgumentNullException("Vendor model is null.");
            }
            vendor = Db.tblM_Vendor.Find(vendorDTO.Vendor_PK);
            if (vendor == null)
            {
                throw new KairosException($"Record with key '{vendorDTO.Vendor_PK}' is not found.");
            }

            vendor.UpdateValueFrom(vendorDTO, "Vendor_PK", "Status_FK");
            vendorDTO.CreatedBy   = vendor.CreatedBy;
            vendorDTO.CreatedDate = vendor.CreatedDate;
            vendor.UpdatedBy      = vendorDTO.UpdatedBy = User.Username;
            vendor.UpdatedDate    = vendorDTO.UpdatedDate = dateStamp;

            return(vendor);
        }
Exemplo n.º 5
0
        public SaveResult <VendorEntryModel> Save(VendorDTO vendorDTO, DateTime dateStamp)
        {
            ModelValidationResult validationResult = vendorValidator.Validate(vendorDTO);
            bool             success = false;
            VendorEntryModel model   = null;

            if (validationResult.IsValid)
            {
                success = true;
                UpdateVendor(vendorDTO, dateStamp);
                Db.SaveChanges();
                model = vendorEntryDataProvider.Get(vendorDTO.Vendor_PK);
            }

            return(new SaveResult <VendorEntryModel>
            {
                Success = success,
                Message = validationResult.IsValid ? "Data successfully updated." : "Validation error occured.",
                Model = model,
                ValidationResult = validationResult
            });
        }
Exemplo n.º 6
0
        public VendorDTO GetByPrimaryKey(int?primaryKey)
        {
            VendorDTO record = GetQuery().FirstOrDefault(vendor => vendor.Vendor_PK == primaryKey);

            return(record);
        }