Пример #1
0
        public async Task <IActionResult> PutInformalEducation(long id, InformalEducation informalEducation)
        {
            if (id != informalEducation.Id)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
        public async Task <int> DeleteAsync(int id)
        {
            InformalEducation model = await ReadByIdAsync(id);

            EntityExtension.FlagForDelete(model, IdentityService.Username, UserAgent, true);
            DbSet.Update(model);
            return(await DbContext.SaveChangesAsync());
        }
        public async Task <int> UpdateAsync(int id, InformalEducation model)
        {
            var data = await ReadByIdAsync(id);

            data.HeldBy      = model.HeldBy;
            data.StartDate   = model.StartDate;
            data.EndDate     = model.EndDate;
            data.Description = model.Description;
            data.Certificate = model.Certificate;

            DbSet.Update(data);
            return(await DbContext.SaveChangesAsync());
        }
Пример #4
0
        public async Task <ActionResult <InformalEducation> > PostinformalEducation([FromBody] InformalEducationFormViewModel informalEducation)
        {
            VerifyUser();

            /*if (CloudStorageAccount.TryParse(config.Value.StorageConnection, out CloudStorageAccount storageAccount))
             * {
             *  CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();
             *
             *  CloudBlobContainer container = blobClient.GetContainerReference(config.Value.Container);
             *
             *  var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
             *  var stringChars = new char[8];
             *  var random = new Random();
             *  for (int i = 0; i < stringChars.Length; i++)
             *  {
             *      stringChars[i] = chars[random.Next(chars.Length)];
             *  }
             *
             *  var finalString = new String(stringChars);
             *  CloudBlockBlob blockBlob = container.GetBlockBlobReference(finalString + stream.FileName);
             *
             *  string fileUrl = blockBlob?.Uri.ToString();
             *  informalEducation.FileURL = fileUrl.ToString();
             *
             *  await blockBlob.UploadFromStreamAsync(stream.OpenReadStream());
             *
             * }
             * else
             * {
             *  return null;
             * }*/

            var model = new InformalEducation()
            {
                Certificate = informalEducation.Certificate.GetValueOrDefault(),
                Description = informalEducation.Description,
                JobPosition = informalEducation.JobPosition,
                EndDate     = informalEducation.EndDate,
                HeldBy      = informalEducation.HeldBy,
                StartDate   = informalEducation.StartDate,
                FileURL     = informalEducation.FileURL
            };

            EntityExtension.FlagForCreate(model, _identityService.Username, UserAgent);
            _context.InformalEducations.Add(model);
            await _context.SaveChangesAsync();

            return(Created("", model));
        }
Пример #5
0
        public async Task <ActionResult <InformalEducation> > PostinformalEducation([FromBody] InformalEducationFormViewModel informalEducation)
        {
            VerifyUser();
            var model = new InformalEducation()
            {
                Certificate = informalEducation.Certificate.GetValueOrDefault(),
                Description = informalEducation.Description,
                EndDate     = informalEducation.EndDate,
                HeldBy      = informalEducation.HeldBy,
                StartDate   = informalEducation.StartDate
            };

            EntityExtension.FlagForCreate(model, _identityService.Username, UserAgent);
            _context.InformalEducations.Add(model);
            await _context.SaveChangesAsync();

            return(Created("", model));
        }
 public async Task <int> CreateAsync(InformalEducation model)
 {
     EntityExtension.FlagForCreate(model, IdentityService.Username, UserAgent);
     DbSet.Add(model);
     return(await DbContext.SaveChangesAsync());
 }