public IHttpActionResult PutAssetUsageLog(int id, AssetUsageLog assetUsageLog)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != assetUsageLog.Id)
            {
                return(BadRequest());
            }

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
Example #2
0
 public ActionResult Save(AssetUsageLog assetsUL)
 {
     if (!ModelState.IsValid)
     {
         var viewModel = new AssetUsageLogViewModel(assetsUL)
         {
             FixedAssets = _context.FixedAssets.ToList()
         };
         return(View("UsageLog", viewModel));
     }
     if (assetsUL.Id == 0)
     {
         assetsUL.Trans_Date = DateTime.Now;
         _context.AssetUsagelogs.Add(assetsUL);
     }
     else
     {
         var assetsULInDb = _context.AssetUsagelogs.Single(m => m.Id == assetsUL.Id);
         assetsULInDb.FixedAssetId        = assetsUL.FixedAssetId;
         assetsULInDb.Trans_Date          = assetsUL.Trans_Date;
         assetsULInDb.StartTime           = assetsUL.StartTime;
         assetsULInDb.EndDate             = assetsUL.EndDate;
         assetsULInDb.Destination         = assetsUL.Destination;
         assetsULInDb.StaffIdentification = assetsUL.StaffIdentification;
     }
     _context.SaveChanges();
     return(RedirectToAction("UsageLog", "AUL"));
 }
Example #3
0
        public ActionResult DeleteConfirmed(int id)
        {
            AssetUsageLog assetUsageLog = _context.AssetUsagelogs.Find(id);

            _context.AssetUsagelogs.Remove(assetUsageLog);
            _context.SaveChanges();
            return(RedirectToAction("Index"));
        }
        public IHttpActionResult GetAssetUsageLog(int id)
        {
            AssetUsageLog assetUsageLog = db.AssetUsagelogs.Find(id);

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

            return(Ok(assetUsageLog));
        }
Example #5
0
        public AssetUsageLogViewModel(AssetUsageLog aul)
        {
            Id                  = aul.Id;
            Trans_Date          = aul.Trans_Date;
            StartTime           = aul.StartTime;
            EndDate             = aul.EndDate;
            Destination         = aul.Destination;
            StaffIdentification = aul.StaffIdentification;

            FixedAssetId = aul.FixedAssetId;
        }
Example #6
0
 public ActionResult Edit([Bind(Include = "Id,FixedAssetId,Trans_Date,StartTime,EndDate,Destination,StaffIdentification")] AssetUsageLog assetUsageLog)
 {
     if (ModelState.IsValid)
     {
         _context.Entry(assetUsageLog).State = EntityState.Modified;
         _context.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.FixedAssetId = new SelectList(_context.FixedAssets, "Id", "Description", assetUsageLog.FixedAssetId);
     return(View(assetUsageLog));
 }
        public IHttpActionResult PostAssetUsageLog(AssetUsageLog assetUsageLog)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.AssetUsagelogs.Add(assetUsageLog);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = assetUsageLog.Id }, assetUsageLog));
        }
        public IHttpActionResult DeleteAssetUsageLog(int id)
        {
            AssetUsageLog assetUsageLog = db.AssetUsagelogs.Find(id);

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

            db.AssetUsagelogs.Remove(assetUsageLog);
            db.SaveChanges();

            return(Ok(assetUsageLog));
        }
Example #9
0
        // GET: AssetUsageLogs/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            AssetUsageLog assetUsageLog = _context.AssetUsagelogs.Find(id);

            if (assetUsageLog == null)
            {
                return(HttpNotFound());
            }
            ViewBag.FixedAssetId = new SelectList(_context.FixedAssets, "Id", "Description", assetUsageLog.FixedAssetId);
            return(View(assetUsageLog));
        }
Example #10
0
        // GET: AssetUsageLogs/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            //AssetUsageLog assetUsageLog = _context.AssetUsagelogs.Find(id);
            AssetUsageLog assetUsageLog = _context.AssetUsagelogs.Include(a => a.FixedAsset).SingleOrDefault(a => a.Id == id);

            if (assetUsageLog == null)
            {
                return(HttpNotFound());
            }
            return(View(assetUsageLog));
        }