public IHttpActionResult DeletePOMASTER(string id)
        {
            PoMasterModel poMaster = _poMasterRepository.GetPoMasterById(id);

            if (poMaster == null)
            {
                return(NotFound());
            }
            _poMasterRepository.DeletePoMaster(id);
            return(Ok());
        }
        public IHttpActionResult PutPOMASTER(string id, PoMasterModel poMaster)
        {
            string poNo = _poMasterRepository.UpdatePoMaster(poMaster);

            if (poNo == string.Empty)
            {
                throw new Exception("Falied to update");
            }

            return(Content(HttpStatusCode.Accepted, poMaster));
        }
        public IHttpActionResult PostPOMASTER(PoMasterModel poMaster)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            string poNo = _poMasterRepository.AddPoMaster(poMaster);

            return(CreatedAtRoute("DefaultApi", new { id = poNo }, poMaster));
        }
Example #4
0
        public void DeletePoMasterTest()
        {
            PoMasterModel model = new PoMasterModel {
                PONO = "2", SUPLNO = "1"
            };

            mockPoMasterRepository.Setup(s => s.GetPoMasterById(model.PONO)).Returns(model);
            var result = controller.DeletePOMASTER(model.PONO);

            Assert.IsInstanceOfType(result, typeof(OkResult));
        }
Example #5
0
        public void AddPoMasterTest()
        {
            PoMasterModel model = new PoMasterModel {
                PONO = "1"
            };

            mockPoMasterRepository.Setup(s => s.AddPoMaster(It.IsAny <PoMasterModel>())).Returns(Task.FromResult(model.PONO).Result);
            var result = controller.PostPOMASTER(model) as CreatedAtRouteNegotiatedContentResult <PoMasterModel>;

            Assert.AreEqual(model.PONO, result.Content.PONO);
        }
        public List <PoMasterModel> GetAllPOMasters()
        {
            List <PoMasterModel> poMasters = new List <PoMasterModel>();

            foreach (var poMaster in _context.POMASTERs)
            {
                PoMasterModel objPoMaster = GetPoMasterModel(poMaster);
                poMasters.Add(objPoMaster);
            }
            return(poMasters);
        }
        private static POMASTER GetPoMasterEntity(PoMasterModel poMaster)
        {
            POMASTER poMasterEntity = new POMASTER();

            if (poMaster != null)
            {
                poMasterEntity.PONO   = poMaster.PONO;
                poMasterEntity.PODATE = poMaster.PODATE;
                poMasterEntity.SUPLNO = poMaster.SUPLNO;
            }
            return(poMasterEntity);
        }
        private static PoMasterModel GetPoMasterModel(POMASTER poMasterEntity)
        {
            PoMasterModel objPoMaster = new PoMasterModel();

            if (poMasterEntity != null)
            {
                objPoMaster.PODATE   = poMasterEntity.PODATE;
                objPoMaster.PONO     = poMasterEntity.PONO;
                objPoMaster.SUPLNO   = poMasterEntity.SUPLNO;
                objPoMaster.SUPLNAME = poMasterEntity.SUPPLIER?.SUPLNAME;
            }
            return(objPoMaster);
        }
        public string UpdatePoMaster(PoMasterModel poMaster)
        {
            string   result         = string.Empty;
            POMASTER poMasterEntity = GetPoMasterEntity(poMaster);

            if (poMasterEntity != null)
            {
                _context.Entry(poMasterEntity).State = EntityState.Modified;
                _context.SaveChanges();
                result = poMasterEntity.PONO;
            }
            return(result);
        }
Example #10
0
        public void UpdatePoMasterTest()
        {
            PoMasterModel model = new PoMasterModel {
                PONO = "1"
            };

            mockPoMasterRepository.Setup(s => s.UpdatePoMaster(It.IsAny <PoMasterModel>())).Returns(Task.FromResult(model.PONO).Result);
            var result = controller.PutPOMASTER(model.PONO, model) as NegotiatedContentResult <PoMasterModel>;

            Assert.IsNotNull(result);
            Assert.AreEqual(HttpStatusCode.Accepted, result.StatusCode);
            Assert.IsNotNull(result.Content);
            Assert.AreEqual(model.SUPLNO, result.Content.SUPLNO);
        }
Example #11
0
        public string AddPoMaster(PoMasterModel poMaster)
        {
            string result = string.Empty;

            POMASTER poMasterEntity = GetPoMasterEntity(poMaster);

            if (poMasterEntity != null)
            {
                _context.POMASTERs.Add(poMasterEntity);
                _context.SaveChanges();
                result = poMasterEntity.PONO;
            }
            return(result);
        }
        public IHttpActionResult GetPOMASTER(string id)
        {
            PoMasterModel poMaster = _poMasterRepository.GetPoMasterById(id);

            return(Ok(poMaster));
        }