public async Task <ActionResult> Create([Bind(Include = "Id,Position,ImageUrl,StudentProfile,Location,CreateOn,ValidUntil,Description,IsDeleted")] JobAd jobAd)
        {
            if (ModelState.IsValid)
            {
                db.JobAds.Add(jobAd);
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }

            return(View(jobAd));
        }
Exemplo n.º 2
0
        public async Task <ActionResult> Create([Bind(Include = "Id,ApplyStatus")] Apply apply)
        {
            if (ModelState.IsValid)
            {
                db.Applies.Add(apply);
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }

            return(View(apply));
        }
Exemplo n.º 3
0
        public virtual async Task <UserProject> AddAsync(UserProject entity)
        {
            if (entity == null)
            {
                throw new ArgumentNullException($"{nameof(AddAsync)} entity must not be null");
            }

            try
            {
                await _context.AddAsync(entity);

                await _context.SaveChangesAsync();

                return(entity);
            }
            catch (Exception ex)
            {
                throw new Exception($"{nameof(entity)} could not be saved: {ex.Message}");
            }
        }
Exemplo n.º 4
0
        // PUT: odata/JobAds2(5)
        public async Task <IHttpActionResult> Put([FromODataUri] int key, Delta <JobAd> patch)
        {
            Validate(patch.GetEntity());

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

            JobAd jobAd = await db.JobAds.FindAsync(key);

            if (jobAd == null)
            {
                return(NotFound());
            }

            patch.Put(jobAd);

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!JobAdExists(key))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(Updated(jobAd));
        }