public long Add(Vendor obj)
        {
            if (IsDuplicate(obj.VendorCode, obj.Id, obj.CustomerId) == false)
            {
                return(_vendorRepository.Add(obj));
            }
            else
            {
                Expression <Func <Vendor, bool> > res = x => x.VendorCode == obj.VendorCode && x.CustomerId == obj.CustomerId && x.IsActive == false;
                var model = _vendorRepository.Get(res);

                if (model != null)
                {
                    obj.Id       = model.Id;
                    obj.IsActive = true;

                    _vendorRepository.Detach(model);

                    _vendorRepository.Update(obj);

                    return(obj.Id);
                }
                else
                {
                    return(0);
                }
            }
        }
Beispiel #2
0
        public async Task CanGetAll()
        {
            Collection.Add(_vendor);
            var result = await _repository.Get().ToListAsync();

            Assert.Single(result);
        }
Beispiel #3
0
        public Vendor GetVendorById(int id)
        {
            var obj = _vendorRepository.Get(c => c.Id == id);

            //var obj = _vendorRepository.GetAll().Where(p=>p.Id==id).FirstOrDefault();
            //var obj = _vendorRepository.GetById(id);
            //var obj = _vendorRepository.GetMany(p => p.Id == id).FirstOrDefault();
            return(obj);
        }
Beispiel #4
0
        public Vendor GetVendorDetails(int vendorId)
        {
            var vendor = Vendor.MapFromEntity(_vendorRepository.Get(vendorId));

            vendor.Invoices  = _invoiceManager.GetInvoicesForVendor(vendorId);
            vendor.Tickets   = _ticketManager.GetTicketsForVendor(vendorId);
            vendor.Materials = _materialManager.GetMaterialsForVendor(vendorId);

            return(vendor);
        }
Beispiel #5
0
        public VendorEntity Get(Guid VendorId)
        {
            Vendor Vendor = vendorRepository.Get(VendorId);

            if (Vendor == null)
            {
                return(null);
            }
            VendorEntity VendorEntity = new VendorEntity(Vendor);

            return(VendorEntity);
        }
Beispiel #6
0
        public async Task <IActionResult> Get(string code)
        {
            var vendor = await _vendorRepository.Get(code);

            if (vendor == null)
            {
                return(NotFound("Vendor not found!"));
            }
            else
            {
                return(Ok(vendor));
            }
        }
        public void Update(parameters.UpdateVendorParameter param)
        {
            param.Validate();
            Vendor vendor = _repository.Get(param.Id);

            assertVendorNotNull(vendor);

            if (!vendor.Code.Equals(param.Code))
            {
                assertVendorNotExist(param.Code, vendor.OrganizationId);
            }
            if (!vendor.CurrencyId.Equals(param.CurrencyId))
            {
                assertCurrencyAlreadyExist(param.CurrencyId, vendor.OrganizationId);
            }
            if (!vendor.PaymentTermId.Equals(param.PaymentTermId))
            {
                assertPaymentTermAlreadyExist(param.PaymentTermId, vendor.OrganizationId);
            }

            vendor.Update(param);
            _repository.Update(vendor);
        }
Beispiel #8
0
 public IActionResult Get()
 {
     try {
         string vendors       = _vendorRepository.Get();
         string jsonFormatted = JValue.Parse(vendors).ToString(Formatting.Indented);
         return(StatusCode(200, jsonFormatted));
     }
     catch (Exception ex) {
         dynamic response = new ExpandoObject();
         response.ErrorMsg = ex.Message;
         string errMsg = JsonConvert.SerializeObject(response, Formatting.Indented);
         return(BadRequest(errMsg));
     }
 }
        public IActionResult Edit(int?id)
        {
            var userID = User.FindFirstValue(ClaimTypes.NameIdentifier);

            if (id == null)
            {
                return(BadRequest());
            }

            //Make sure user owns vendor.
            if (!_vendorRepository.UserOwnsVendor((int)id, userID))
            {
                return(NotFound());
            }

            //Get the vendor data
            Vendor vendor = _vendorRepository.Get((int)id, userID);

            //Don't allow users to edit default vendors.
            if (!vendor.IsDefault)
            {
                //Convert DBVendor to VMVendor
                EntityViewModel vm = new EntityViewModel();
                vm.EntityOfInterest = new EntityViewModel.Entity
                {
                    EntityID    = vendor.VendorID,
                    Name        = vendor.Name,
                    IsDisplayed = vendor.IsDisplayed
                };

                return(View(vm));
            }

            TempData["BadMessage"] = "Adjustment of default vendor is not allow.";

            return(RedirectToAction("Index"));
        }
Beispiel #10
0
        public void UpdateVendor(UpdateVendorInput input)
        {
            var vendor = _vendorRepository.Get(input.Id);

            vendor.VendorCode          = input.VendorCode;
            vendor.VendorName          = input.VendorName;
            vendor.VendorAddress       = input.VendorAddress;
            vendor.VendorContactEmail  = input.VendorContactEmail;
            vendor.VendorContactNumber = input.VendorContactNumber;
            vendor.VendorFax           = input.VendorFax;
            vendor.VendorWebsite       = input.VendorWebsite;
            vendor.VendorContactPerson = input.VendorContactPerson;
            vendor.VendorBankDetails   = input.VendorBankDetails;

            _vendorRepository.Update(vendor);
        }
Beispiel #11
0
        public Task <bool> VendorNameNotExists(string vendorName, CancellationToken token)
        {
            var vendor = _vendorRepository.Get().FirstOrDefault(x => x.Name == vendorName);

            return(Task.FromResult(vendor is null));
        }
Beispiel #12
0
        public ActionResult Get(int id)
        {
            var apiResult = TryExecute(() => _vendorRepository.Get(id), "Holiday fetched sucessfully");

            return(Json(apiResult, JsonRequestBehavior.AllowGet));
        }
Beispiel #13
0
        // GET: api/Vendors/5
        public IHttpActionResult Get(Guid id)
        {
            var data = vendorRepository.Get(id);

            return(Ok(data));
        }
Beispiel #14
0
        public async Task <IActionResult> Get(string id)
        {
            var vendor = await _vendorRepository.Get(id);

            return(Ok(vendor));
        }