Exemple #1
0
 public async Task <string> GetDocsNameByIDAsync(int id, EntityContextWEB context)
 {
     return(await context.PlanDocs
            .Where(c => c.ID == id)
            .Select(c => c.DocsName)
            .FirstOrDefaultAsync());
 }
Exemple #2
0
 public async Task <List <Users> > GetsAsync(EntityContextWEB context)
 {
     return(await context.Users
            .Select(c => new Users {
         ID = c.ID, EmployeeCode = c.EmployeeCode, RoleName = c.Roles.RoleName, AddDate = c.AddDate
     })
            .ToListAsync());
 }
Exemple #3
0
        public async Task <Users> InsertAsync(Users users, EntityContextWEB context)
        {
            users.AddBy = Current.UserID;
            context.Users.Add(users);
            await context.SaveChangesAsync();

            return(users);
        }
Exemple #4
0
        public async Task UpdateAsync(Users users, EntityContextWEB context)
        {
            var Users = context.Users;
            var u     = Users.Attach(users);

            u.Property(c => c.EmployeeCode).IsModified = true;
            u.Property(c => c.AddBy).CurrentValue      = Current.UserID;
            await context.SaveChangesAsync();
        }
        public async Task <List <CommRates> > GetByPlanCodeAsync(string Plancode, EntityContextWEB context)
        {
            if (Plancode.Length > 4)
            {
                Plancode = Plancode.Substring((Plancode.Length - 4), 4);
            }

            return(await context.CommRates
                   .Where(c => c.PlanCodeExcludeYear.Contains(Plancode))
                   .ToListAsync());
        }
Exemple #6
0
 public async Task <List <PlanDocs> > GetDocByIDAsync(PlanDocs model, EntityContextWEB context)
 {
     if (model.PlanCode == "All")
     {
         return(await context.PlanDocs.ToListAsync());
     }
     else
     {
         return(await context.PlanDocs
                .Where(c => c.PlanCode == model.PlanCode)
                .Select(c => new PlanDocs {
             ID = c.ID
         })
                .ToListAsync());
     }
 }
Exemple #7
0
        public async Task <Users> AdminLoginAsync(string username, string password, EntityContextWEB context)
        {
            if (string.IsNullOrEmpty(password))
            {
                password = "";
            }

            return(await context.Users
                   .Include(c => c.Roles)
                   .Where(c => c.EmployeeCode == username)
                   .Select(c => new Users
            {
                EmployeeCode = c.EmployeeCode,
                RoleName = c.Roles.RoleName
            })
                   .FirstOrDefaultAsync());
        }
        public async Task InsertAsync(AnnounceMathDocs model, EntityContextWEB context)
        {
            var isexists = await model.IsExistsDocsNameAsync(model.File.FileName, context);

            if (isexists)
            {
                await context.AnnounceDocs
                .Where(t => t.DocsName == model.DocsName)
                .UpdateAsync(t => new AnnounceMathDocs {
                    LastModifyDate = DateTime.Now, LastModifyBy = Current.UserID
                });
            }
            else
            {
                context.AnnounceDocs.Add(model);
                await context.SaveChangesAsync();
            }
        }
Exemple #9
0
 public AnnounceController(EntityContextWEB _contextWeb, IOptions <AppSettings> _appSettings)
 {
     contextWeb  = _contextWeb;
     appSettings = _appSettings.Value;
 }
        public async Task <AnnounceMathDocs> UploadFileAsync(AnnounceMathDocs announce, string initialPath, EntityContextWEB context)
        {
            string path = Path.Combine(initialPath, announce.File.FileName);

            //<--- Create Directory if it is not exists.
            if (!Directory.Exists(initialPath))
            {
                Directory.CreateDirectory(initialPath);
            }
            //<--- Delete current file if the new file have same name as current file.
            if (File.Exists(path))
            {
                File.Delete(path);
            }

            //<--- Save file.
            using (FileStream stream = new FileStream(path, FileMode.Create))
            {
                await announce.File.CopyToAsync(stream);
            }
            //<--- Insert Data.
            await InsertAsync(announce, context);

            return(announce);
        }
Exemple #11
0
 public async Task <List <CommRates> > GetAsync(EntityContextWEB context)
 {
     return(await context.CommRates.ToListAsync());
 }
Exemple #12
0
 public async Task DeleteAsync(Users users, EntityContextWEB context)
 {
     context.Users.Remove(users);
     await context.SaveChangesAsync();
 }
Exemple #13
0
 public async Task DeleteAsync(CommRates commRate, EntityContextWEB context)
 {
     context.CommRates.Remove(commRate);
     await context.SaveChangesAsync();
 }
 public AdminController(EntityContextWEB contextWeb) => this.contextWeb = contextWeb;
Exemple #15
0
 public async Task UpdateAsync(CommRates commRate, EntityContextWEB context)
 {
     context.Entry(commRate).State = EntityState.Modified;
     await context.SaveChangesAsync();
 }
Exemple #16
0
 public UserService(IOptions <AppSettings> _appSettings, EntityContextWEB _contextWeb, EntityContextDocpd _contextDocpd)
 {
     appSettings  = _appSettings.Value;
     contextWeb   = _contextWeb;
     contextDocpd = _contextDocpd;
 }
Exemple #17
0
 public UploadDataController(IDbServices _dbServices, IOptions <AppSettings> _appSettings, EntityContextWEB _contextWeb)
 {
     dbServices  = _dbServices;
     appSettings = _appSettings.Value;
     contextWeb  = _contextWeb;
 }
 public PlanController(IOptions <AppSettings> _appSettings, EntityContextFASTTRACK _contextFt, EntityContextWEB _contextWeb)
 {
     appSettings = _appSettings.Value;
     contextFt   = _contextFt;
     contextWeb  = _contextWeb;
 }
Exemple #19
0
 public async Task DeleteAsync(int id, EntityContextWEB context)
 {
     context.PlanDocs.Remove(context.PlanDocs.Find(id));
     await context.SaveChangesAsync();
 }
Exemple #20
0
 public async Task <bool> IsExistsDocsNameAsync(string docsName, EntityContextWEB context)
 {
     return(await context.PlanDocs.AnyAsync(c => c.DocsName == docsName));
 }
 public async Task <List <AnnounceMathDocs> > GetAnnounceDocsAsync(EntityContextWEB context)
 {
     return(await context.AnnounceDocs.ToListAsync());
 }