public async Task <IActionResult> PutFormDataItems(string id, FormDataItems formDataItems)
        {
            if (id != formDataItems.user_id)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
Esempio n. 2
0
        public async Task <IActionResult> PutColumn(int id, Column column)
        {
            if (id != column.Id)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
Esempio n. 3
0
        public async Task <IActionResult> Create([Bind("LongUrl")] CreateForm url)
        {
            UrlForm form = await context.Form.FirstOrDefaultAsync(p => p.LongUrl == url.LongUrl);

            if (form != null)
            {
            }
            else if (ModelState.IsValid)
            {
                UrlForm newForm = GenerateUrl(url.LongUrl);

                context.Form.Add(newForm);
                await context.SaveChangesAsync();
            }
            return(RedirectToAction("Index"));
        }
Esempio n. 4
0
        public async Task <IActionResult> Create(CreateGroupDTO model)
        {
            if (model.ParentId.HasValue)
            {
                var parentGroupExists = _formContext.Groups.Any(g => g.Id == model.ParentId);
                if (!parentGroupExists)
                {
                    return(BadRequest());
                }
            }

            var groupExists = _formContext.Groups.Any(g => g.GroupName == model.GroupName);

            if (groupExists)
            {
                ModelState.AddModelError("GroupName", "Group with given name already exists");
            }

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var group = new Group()
            {
                GroupName   = model.GroupName,
                Description = model.Description,
                ParentId    = model.ParentId
            };

            try
            {
                await _formContext.Groups.AddAsync(group);

                await _formContext.SaveChangesAsync();

                return(Ok());
            }
            catch (Exception)
            {
                return(StatusCode((int)HttpStatusCode.InternalServerError));
            }
        }
Esempio n. 5
0
        private async void AddApplicantClick(object sender, RoutedEventArgs e)
        {
            var applicant = new Applicant(FirstName.Text, LastName.Text, int.Parse(ApplicantID.Text));
            var context   = new FormContext();

            context.Applicants.Add(applicant);
            await context.SaveChangesAsync();

            ApplicantCreated();
        }
        public async void Save(SaveFormOptions saveBehavior = SaveFormOptions.ShowDialog)
        {
            var context = new FormContext();

            if (newInterview)
            {
                if (saveBehavior != SaveFormOptions.SuppressDialog)
                {
                    context.Interviews.Add(interview);
                    newInterview = false;
                }
            }
            else
            {
                context.Interviews.Update(interview);
            }
            await context.SaveChangesAsync();

            if (saveBehavior == SaveFormOptions.ShowDialog)
            {
                await Notify("Interview saved.");
            }
        }