Exemplo n.º 1
0
        public async Task <string> DeleteAsync(int?Id)
        {
            try
            {
                using (var context = new OLSoftwareDataContext(this.options))
                {
                    var project = context.Projects.FirstOrDefaultAsync(x => x.Id == Id);
                    if (project != null)
                    {
                        context.Remove(project);
                        await context.SaveChangesAsync();

                        return("Success");
                    }
                    else
                    {
                        return("No se encontró el registro");
                    }
                }
            }
            catch (Exception ex)
            {
                return(ex.Message);
            }
        }
Exemplo n.º 2
0
 public async Task <IEnumerable <Project> > GetAllAsync()
 {
     try
     {
         using (var context = new OLSoftwareDataContext(this.options))
         {
             return(await context.Projects.ToListAsync());
         }
     }
     catch (Exception ex)
     {
         return(null);
     }
 }
Exemplo n.º 3
0
 public async Task <Project> GetAsync(int?Id)
 {
     try
     {
         using (var context = new OLSoftwareDataContext(this.options))
         {
             return(await context.Projects.FirstOrDefaultAsync(x => x.Id == Id));
         }
     }
     catch (Exception ex)
     {
         return(null);
     }
 }
Exemplo n.º 4
0
        public async Task <string> UpdateAsync(Project model)
        {
            try
            {
                using (var context = new OLSoftwareDataContext(this.options))
                {
                    context.Entry(model).State = EntityState.Modified;
                    await context.SaveChangesAsync();

                    return("Success");
                }
            }
            catch (Exception ex)
            {
                return(ex.Message);
            }
        }
Exemplo n.º 5
0
        public async Task <string> InsertAsync(Project model)
        {
            try
            {
                using (var context = new OLSoftwareDataContext(this.options))
                {
                    model.Date = new DateTime();
                    context.Projects.Add(model);

                    await context.SaveChangesAsync();

                    return("Success");
                }
            }
            catch (Exception ex)
            {
                return(ex.Message);
            }
        }