Exemplo n.º 1
0
        public async Task <IActionResult> PutCustomer([FromRoute] int id, [FromBody] Customer customer)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != customer.CustomerId)
            {
                return(BadRequest());
            }

            _context.Entry(customer).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!CustomerExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Exemplo n.º 2
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            var saveMethod = (dynamic)null;

            if (id != null)
            {
                saveMethod = await _trainingContext.BioDataTab.FirstOrDefaultAsync(s => s.Id == id);

                if (saveMethod != null)
                {
                    saveMethod.Title         = BioDataTab.Title;
                    saveMethod.Surname       = BioDataTab.Surname;
                    saveMethod.FirstName     = BioDataTab.FirstName;
                    saveMethod.OtherNames    = BioDataTab.OtherNames;
                    saveMethod.Nationality   = BioDataTab.Nationality;
                    saveMethod.State         = BioDataTab.State;
                    saveMethod.LGA           = BioDataTab.LGA;
                    saveMethod.Gender        = BioDataTab.Gender;
                    saveMethod.MaritalStatus = BioDataTab.MaritalStatus;
                    saveMethod.Religion      = BioDataTab.Religion;
                    saveMethod.PhoneNumber   = BioDataTab.PhoneNumber;
                    saveMethod.Email         = BioDataTab.Email;
                    saveMethod.DateofBirth   = BioDataTab.DateofBirth;

                    _trainingContext.BioDataTab.Update(saveMethod);
                }
            }
            else
            {
                saveMethod = new BioDataTab
                {
                    Title         = BioDataTab.Title,
                    Surname       = BioDataTab.Surname,
                    FirstName     = BioDataTab.FirstName,
                    OtherNames    = BioDataTab.OtherNames,
                    Nationality   = BioDataTab.Nationality,
                    State         = BioDataTab.State,
                    LGA           = BioDataTab.LGA,
                    Gender        = BioDataTab.Gender,
                    MaritalStatus = BioDataTab.MaritalStatus,
                    Religion      = BioDataTab.Religion,
                    PhoneNumber   = BioDataTab.PhoneNumber,
                    Email         = BioDataTab.Email,
                    DateofBirth   = BioDataTab.DateofBirth
                };
                _trainingContext.BioDataTab.Add(saveMethod);
            }

            await _trainingContext.SaveChangesAsync();

            return(Redirect("./BioDataList"));
        }
Exemplo n.º 3
0
            public async Task <IActionResult> Create([Bind("CourseID,Credits,Title")] Course course)
            {
                _context.Add(course);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
Exemplo n.º 4
0
        public async Task <TreningModel> Add(TreningModel model)
        {
            try
            {
                var noviTrening = _mapper.Map <Trening>(model);
                _context.Trening.Add(noviTrening);

                await _context.SaveChangesAsync();

                var returnModel = _mapper.Map <TreningModel>(noviTrening);

                return(returnModel);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Exemplo n.º 5
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            var saveMethod = (dynamic)null;

            if (id != null)
            {
                saveMethod = await _trainingContext.BioDataTab.FirstOrDefaultAsync(s => s.Id == id);

                if (saveMethod != null)
                {
                    _trainingContext.BioDataTab.Remove(saveMethod);
                }
            }
            await _trainingContext.SaveChangesAsync();

            return(Redirect("./BioDataList"));
        }
        public async Task <IActionResult> OnPostAsync()
        {
            var saveMethod = new ApplicationTab
            {
                ApplicantName        = ApplicationTab.ApplicantName,
                ApplicantPhoneNumber = ApplicationTab.ApplicantPhoneNumber,
                ApplicantEmail       = ApplicationTab.ApplicantEmail,
                ApplicantAddress     = ApplicationTab.ApplicantAddress,
                PositionApply        = ApplicationTab.PositionApply,
                DateApplied          = DateTime.Now,
                ApplicationStatus    = false,
            };

            _trainingContext.ApplicationTab.Add(saveMethod);

            await _trainingContext.SaveChangesAsync();

            return(Redirect("./ApplicationList"));
        }
        public async Task <bool> Add <T>(T entity) where T : class
        {
            _context.Add(entity);

            return(await _context.SaveChangesAsync() > 0);
        }