public async Task <ResultModel <string> > Add(TestimonyGroupPostVM model)
        {
            var result = new ResultModel <string>();

            //check if Offer Name already exists for vendor
            var check = await _context.TestimonyGroups
                        .Where(m => m.Name == model.Name.ToUpper() && m.Name == model.Name)
                        .FirstOrDefaultAsync();

            if (check != null)
            {
                result.AddError("TestimonyGroup already has Offer with this name");
                return(result);
            }

            var newObject = new TestimonyGroup()
            {
                Name = model.Name,
            };

            _context.TestimonyGroups.Add(newObject);
            await _context.SaveChangesAsync();

            result.Data = "Saved Successfully";
            return(result);
        }
Exemplo n.º 2
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            TeamMember = await _context.TeamMembers.FindAsync(id);

            if (TeamMember != null)
            {
                var path = TeamMember.Image;

                _context.TeamMembers.Remove(TeamMember);
                await _context.SaveChangesAsync();

                var rootFolder = _env.WebRootPath;
                if (System.IO.File.Exists(Path.Combine(rootFolder, path)))
                {
                    System.IO.File.Delete(Path.Combine(rootFolder, path));
                }
            }

            return(RedirectToPage("./Index"));
        }
Exemplo n.º 3
0
        // To protect from overposting attacks, enable the specific properties you want to bind to, for
        // more details, see https://aka.ms/RazorPagesCRUD.
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            _context.Attach(Rank).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!RankExists(Rank.Id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(RedirectToPage("./Index"));
        }
Exemplo n.º 4
0
        // To protect from overposting attacks, enable the specific properties you want to bind to, for
        // more details, see https://aka.ms/RazorPagesCRUD.
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            _context.Ranks.Add(Rank);
            await _context.SaveChangesAsync();

            return(RedirectToPage("./Index"));
        }
Exemplo n.º 5
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Rank = await _context.Ranks.FindAsync(id);

            if (Rank != null)
            {
                _context.Ranks.Remove(Rank);
                await _context.SaveChangesAsync();
            }

            return(RedirectToPage("./Index"));
        }
Exemplo n.º 6
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            try
            {
                if (!_fileStore.ValidateVideoFile(Video, out var error))
                {
                    ModelState.AddModelError(string.Empty, error);
                    return(Page());
                }

                var fileName = await _fileStore.UploadFileAsync(Video);

                if (string.IsNullOrWhiteSpace(fileName))
                {
                    ModelState.AddModelError(string.Empty, "An error occured while uploading file.");
                    return(Page());
                }

                Testimony.Video = fileName;

                _context.Testimonies.Add(Testimony);
                await _context.SaveChangesAsync();
            }
            catch (Exception ex)
            {
                ModelState.AddModelError(string.Empty, ex.Message);
                return(Page());
            }

            return(RedirectToPage("./Index"));
        }