public void Update(MaterialReceptionItem materialReception)
        {
            var entity = Mapper.Map <TX30_Reception>(materialReception);

            _unitOfWork.ReceptionRepository.Update(entity);
            _unitOfWork.Commit();
        }
 public ResponseResult CreateOrUpdate(MaterialReceptionItem model)
 {
     if (model.IsCreate)
     {
         if (!string.IsNullOrEmpty(model.F30_PrcOrdNo) && !string.IsNullOrEmpty(model.F30_PrtDvrNo))
         {
             if (CheckUnique(model.F30_PrcOrdNo, model.F30_PrtDvrNo))
             {
                 return(new ResponseResult(false, Constants.Messages.Material_MSG03));
             }
         }
         var entity = Mapper.Map <TX30_Reception>(model);
         entity.F30_AddDate     = DateTime.Now;
         entity.F30_UpdateDate  = DateTime.Now;
         entity.F30_UpdateCount = 1;
         entity.F30_AcceptClass = Constants.TX30_Reception.NonAccept.ToString("D");
         _unitOfWork.ReceptionRepository.Add(entity);
     }
     else
     {
         var entity = _unitOfWork.ReceptionRepository.GetMany(i => i.F30_PrcOrdNo.Trim().Equals(model.F30_PrcOrdNo.Trim()) && i.F30_PrtDvrNo.Trim().Equals(model.F30_PrtDvrNo.Trim())).FirstOrDefault();;
         if (entity == null)
         {
             return(new ResponseResult(false, Constants.Messages.Material_MSG001));
         }
         Mapper.Map(model, entity);
         entity.F30_UpdateDate = DateTime.Now;
         entity.F30_UpdateCount++;
         _unitOfWork.ReceptionRepository.Update(entity);
     }
     _unitOfWork.Commit();
     return(new ResponseResult(true));
 }
        public ResponseResult <GridResponse <MaterialReceptionItem> > SearchCriteria(string prcOrdNo, string parDelivery, jsGrid.MVC.GridSettings gridSettings)
        {
            var result = _unitOfWork.ReceptionRepository.GetAll();

            if (!string.IsNullOrEmpty(prcOrdNo) && !string.IsNullOrEmpty(parDelivery))
            {
                result = result.Where(i => i.F30_PrcOrdNo.ToUpper().StartsWith(prcOrdNo.ToUpper()) && i.F30_PrtDvrNo.ToUpper().StartsWith(parDelivery.ToUpper()));
            }

            var itemCount = result.Count();

            OrderByAndPaging(ref result, gridSettings);

            var lstMaterialCode = result.Select(i => i.F30_MaterialCode);
            var listMaterial    = _unitOfWork.MaterialRepository.GetAll().Where(i => lstMaterialCode.Contains(i.F01_MaterialCode));
            var lstResult       = new List <MaterialReceptionItem>();

            foreach (var reception in result)
            {
                var materialReceptionItem = new MaterialReceptionItem();
                var lstMaterialItem       = listMaterial.FirstOrDefault(i => i.F01_MaterialCode == reception.F30_MaterialCode);
                if (lstMaterialItem != null)
                {
                    materialReceptionItem.Name = lstMaterialItem.F01_MaterialDsp;
                }
                materialReceptionItem.F30_PrcOrdNo       = reception.F30_PrcOrdNo;
                materialReceptionItem.F30_PrtDvrNo       = reception.F30_PrtDvrNo;
                materialReceptionItem.F30_MaterialCode   = reception.F30_MaterialCode;
                materialReceptionItem.F30_ExpectAmount   = reception.F30_ExpectAmount;
                materialReceptionItem.F30_StoragedAmount = reception.F30_StoragedAmount;
                materialReceptionItem.F30_AcceptClass    = reception.F30_AcceptClass;
                materialReceptionItem.F30_ExpectDate     = reception.F30_ExpectDate;
                lstResult.Add(materialReceptionItem);
            }
            var resultModel = new GridResponse <MaterialReceptionItem>(lstResult, itemCount);

            return(new ResponseResult <GridResponse <MaterialReceptionItem> >(resultModel, true));
        }