public IHttpActionResult PuttblAssetMaster(int id, tblAssetMaster tblAssetMaster)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != tblAssetMaster.am_id)
            {
                return(BadRequest());
            }

            db.Entry(tblAssetMaster).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!tblAssetMasterExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
        public IHttpActionResult GettblAssetMaster(int id)
        {
            tblAssetMaster tblAssetMaster = db.tblAssetMasters.Find(id);

            if (tblAssetMaster == null)
            {
                return(NotFound());
            }

            return(Ok(tblAssetMaster));
        }
        public IHttpActionResult DeletetblAssetMaster(int id)
        {
            tblAssetMaster tblAssetMaster = db.tblAssetMasters.Find(id);

            if (tblAssetMaster == null)
            {
                return(NotFound());
            }

            db.tblAssetMasters.Remove(tblAssetMaster);
            db.SaveChanges();

            return(Ok(tblAssetMaster));
        }
Beispiel #4
0
        public IHttpActionResult PosttblAssetMaster(tblAssetMaster tblAssetMaster)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            for (int i = 0; i < count; i++)
            {
                Random rdm = new Random();
                int    id  = rdm.Next(min++, max++);
                tblAssetMaster.serialnumber = id.ToString();
                db.tblAssetMasters.Add(tblAssetMaster);
                db.SaveChanges();
            }

            return(CreatedAtRoute("DefaultApi", new { id = tblAssetMaster.assetMasterId }, tblAssetMaster));
        }
        public IHttpActionResult PosttblAssetMaster(string orderno, string assetname, string vendorname, string assettype, string quantity, tblAssetMaster tblAssetMaster)
        {
            try
            {
                var asDef  = db.tblAssetDefs.Where(x => x.ad_name == assetname).FirstOrDefault();
                var type   = db.tblAssetTypes.Where(x => x.at_name == assettype).FirstOrDefault();
                var vendor = db.tblVendorCreations.Where(x => x.vd_name == vendorname).FirstOrDefault();
                tblAssetMaster.am_ad_id    = asDef.ad_id;
                tblAssetMaster.am_atype_id = type.at_id;
                tblAssetMaster.am_make_id  = vendor.vd_id;
                var purchase = db.tblPurchaseOrders.Where(x => x.pd_orderno == orderno).FirstOrDefault();
                purchase.pd_status = "Assets Added";
                db.Entry(purchase).Property("pd_status").IsModified = true;
                db.SaveChanges();
            }
            catch (Exception ex)
            {
                Log.Debug(ex.Message);
            }
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            int    count = Convert.ToInt32(quantity);
            Random r     = new Random();

            for (int i = 0; i < count; i++)
            {
                tblAssetMaster.am_snumber = "S" + r.Next(0, 10000);
                db.tblAssetMasters.Add(tblAssetMaster);
                db.SaveChanges();
            }


            return(CreatedAtRoute("DefaultApi", new { id = tblAssetMaster.am_id }, tblAssetMaster));
        }