예제 #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);
            }
        }
예제 #2
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);
            }
        }
예제 #3
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);
            }
        }