52 lines
1.6 KiB
C#
52 lines
1.6 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data.Entity;
|
|
using System.Linq;
|
|
using System.Web;
|
|
using Weee.DAL;
|
|
using Weee.Models;
|
|
|
|
namespace Weee.Service
|
|
{
|
|
public class WeeeCompanyDataService: WeeeDataAuthorizeService
|
|
{
|
|
|
|
public WeeeCompanyDataService(WeeeDataContext db) : base(db)
|
|
{
|
|
}
|
|
|
|
public Company GetCurrentCompany()
|
|
{
|
|
return CurrentCompany;
|
|
}
|
|
|
|
public CertificationCompany GetCertificationCompanyById(int Id)
|
|
{
|
|
return _db.CertificationCompanies.Where(x => x.ID == Id).First();
|
|
}
|
|
|
|
public IEnumerable<object> GetCertificationCompanyNameIDList()
|
|
{
|
|
return _db.CertificationCompanies.Where(x => x.Status == CompanyStatus.Active).Select(x => new { x.ID, x.Name }).ToList();
|
|
}
|
|
|
|
public IEnumerable<object> GetNormalCompanyNameIDEmailList()
|
|
{
|
|
return _db.NormalCompanies
|
|
.Where(x => x.Status == CompanyStatus.Active)
|
|
.Select(x => new { x.ID, x.Name, x.Users.Where(y => y.IsCompanyAdmin).FirstOrDefault().Email })
|
|
.ToList();
|
|
}
|
|
|
|
public void SaveCompanyDetail(NormalCompany ToBeSave)
|
|
{
|
|
var entry = _db.Entry(ToBeSave);
|
|
entry.State = EntityState.Modified;
|
|
entry.Property(x => x.UID).IsModified = false;
|
|
entry.Property(x => x.LastStatusUpdateDate).IsModified = false;
|
|
entry.Property(x => x.Status).IsModified = false;
|
|
entry.Property(x => x.RegisterDate).IsModified = false;
|
|
_db.SaveChanges();
|
|
}
|
|
}
|
|
} |