Exemple #1
0
        public async Task <IActionResult> PutSCxItemAsync(Guid id, SCxItem sCxItem)
        {
            if (id != sCxItem.Id)
            {
                return(BadRequest());
            }
            else if (!SCxItemExists(id))
            {
                return(NotFound());
            }
            else
            {
                _context.Entry(sCxItem).State = EntityState.Modified;

                try
                {
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    throw;
                }

                return(NoContent());
            }
        }
 public async Task <IActionResult> EditUpdate(Guid id, [FromForm, Bind("Id,TimeStamp,Type,Dept,Food,Supplier,CheckUBD,Temperature,Comment,SignOff")] SCxItem sCxItem)
 {
     if (ModelState.IsValid)
     {
         try
         {
             if (id != sCxItem.Id)
             {
                 return(BadRequest("BadRequest:EditUpdate - id Mismatch."));
             }
             else if (!SCxItemExists(sCxItem.Id))
             {
                 return(NotFound("NotFound:EditUpdate - id Not Found."));
             }
             else
             {
                 _context.Update(sCxItem);
                 await _context.SaveChangesAsync();
             }
         }
         catch (DbUpdateConcurrencyException)
         {
             throw;
         }
         return(RedirectToAction(nameof(Index)));
     }
     return(View(sCxItem));
 }
        //[Route("~/SCxView/Create")]
        /// <summary>
        ///     GET: SCxItems/Create - Create new Document.
        ///     This method returns an initialised SCx Document shell to Create View
        /// </summary>
        public IActionResult Create()
        {
            var sCxItem = new SCxItem {
            };

            sCxItem.Initialise(sCxItem);
            return(View(sCxItem));
        }
 /// <summary>
 ///     This method gets called by the runtime and configures the Database context.
 /// </summary>
 public SCxViewController(SCxItemContext context)
 {
     _context = context;
     if (!_context.SCxItems.Any())
     {                                       // If no data - setup test data for the last 31 days.
         foreach (SCxItem sCxItem in SCxItem.AddThisMonthsSCxData(0))
         {
             _context.SCxItems.Add(sCxItem);
         }
         _context.SaveChangesAsync();
     }
 }
Exemple #5
0
 /// <summary>Set Razor Pages Databas Context</summary>
 public IndexModel(DbWebAPI.Models.SCxItemContext context)
 {
     _context = context;
     if (!_context.SCxItems.Any())
     {                                           // If no data - setup test data for the last 31 days.
         foreach (SCxItem sCxItem in SCxItem.AddThisMonthsSCxData())
         {
             _context.SCxItems.Add(sCxItem);
         }
         _context.SaveChangesAsync();
     }
 }
Exemple #6
0
 /// <summary>
 ///     This method gets called by the runtime and configures the Database context.
 /// </summary>
 public SCxItemsController(SCxItemContext context)
 {
     _context = context;
     if (!_context.SCxItems.Any())
     {                                               // If no data - setup test data for the past 3 years.
         for (var month = 0; month <= 36; month++)
         {
             foreach (SCxItem sCxItem in SCxItem.AddThisMonthsSCxData(month))
             {
                 _context.SCxItems.Add(sCxItem);
             }
             _context.SaveChangesAsync();
         }
     }
 }
Exemple #7
0
        public async Task <ActionResult <SCxItem> > PostSCxItemAsync(SCxItem sCxItem)
        {
            if (SCxItemExists(sCxItem.Id))
            {
                return(Conflict());
            }
            sCxItem.Initialise(sCxItem);            // Default Class initialisation for uninitialise attributes
            _context.SCxItems.Add(sCxItem);
            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateException)
            {
                throw;
            }

            return(CreatedAtAction(nameof(GetSCxItemAsync), new { id = sCxItem.Id }, sCxItem));
        }
 public async Task <IActionResult> CreateConfirmed([FromForm, Bind("Id,TimeStamp,Type,Dept,Food,Supplier,CheckUBD,Temperature,Comment,SignOff")] SCxItem sCxItem)
 {
     if (ModelState.IsValid)
     {
         try
         {
             if (SCxItemExists(sCxItem.Id))
             {
                 return(BadRequest("BadRequest:CreateConfirmed - id Already Exists."));
             }
             else
             {
                 _context.Add(sCxItem);
                 await _context.SaveChangesAsync();
             }
         }
         catch (Exception)
         {
             throw;
         }
         return(RedirectToAction(nameof(Index)));
     }
     return(View(sCxItem));
 }