Example #1
0
        public async Task <IActionResult> AddGroundActivity([FromBody] AppGroundActivity model)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    logger.LogInformation("Ground Activity Starts Adding one ground activity");
                    var groundActivityNew = await groundLogistics.AddGroundActity(model);

                    if (groundActivityNew != null)
                    {
                        return(Ok(groundActivityNew));
                    }
                    else
                    {
                        return(NotFound());
                    }
                }
                catch (Exception excp)
                {
                    logger.LogError("Error in adding ground Activity issued here " + excp.Message);
                    return(BadRequest(excp));
                }
            }

            return(BadRequest());
        }
Example #2
0
        public async Task <IActionResult> UpdateGroundActivity([FromBody] AppGroundActivity grActivity)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    logger.LogInformation("Updating ground activity for single activity");
                    await groundLogistics.UpdateGroundActivity(grActivity);

                    return(Ok());
                }
                catch (Exception excp)
                {
                    logger.LogError(" Unable to update activity " + excp.Message);

                    if (excp.GetType().FullName ==
                        "Microsoft.EntityFrameworkCore.DbUpdateConcurrencyException")
                    {
                        return(NotFound());
                    }

                    return(BadRequest(excp));
                }
            }

            return(BadRequest());
        }
Example #3
0
        public async Task <AppGroundActivity> UpdateGroundActivity(AppGroundActivity activity)
        {
            if (db != null)
            {
                //Delete that post
                db.AppGroundActivity.Update(activity);

                //Commit the transaction
                await db.SaveChangesAsync();
            }

            return(activity);
        }
Example #4
0
        public async Task <AppGroundActivity> AddGroundActity(AppGroundActivity groundActivity)
        {
            if (db != null)
            {
                groundActivity.AppGroundActivityId = Guid.NewGuid();
                groundActivity.CreatedDate         = DateTime.Now;
                await db.AppGroundActivity.AddAsync(groundActivity);

                await db.SaveChangesAsync();

                return(groundActivity);
            }

            return(groundActivity);
        }