public List <ProductVM> SelectList() { List <ProductVM> list = new List <ProductVM>(); using (PHOTOLIODBContext context = new PHOTOLIODBContext()) { return(list = context.ProductDMs .Join(context.CategoryDMs, p => p.CategoryId, c => c.Id, (p, c) => new { p, c }) .Where(w => w.p.IsDelete == false) .Select(s => new ProductVM { Id = s.p.Id, UserId = s.p.UserId, Version = s.p.Version, Photo = s.p.Photo, Name = s.p.Name, Description = s.p.Description, Price = s.p.Price, CategoryId = s.p.CategoryId, CategoryName = s.c.Name, }).ToList()); } }
public int Save(ContactUsVM vmEntity) { long time = DateTime.Now.Ticks; int effectedRowCount = 0; ContactUsDM dmEntity = new ContactUsDM(); //dmEntity.UserId = vmEntity.UserId; dmEntity.Name = vmEntity.Name; dmEntity.Email = vmEntity.Email; dmEntity.Message = vmEntity.Message; dmEntity.Version = time; dmEntity.CreatedUserId = vmEntity.CreatedUserId; dmEntity.CreatedDate = vmEntity.CreatedDate; dmEntity.UpdatedUserId = vmEntity.UpdatedUserId; dmEntity.UpdatedDate = vmEntity.UpdatedDate; using (PHOTOLIODBContext context = new PHOTOLIODBContext()) { context.ContactUsDMs.Add(dmEntity); effectedRowCount = context.SaveChanges(); } return(effectedRowCount); }
public int Save(OrderVM inputVM) { OrderDM inputDM = new OrderDM(); inputDM.UserId = inputVM.UserId; inputDM.ProductId = inputVM.ProductId; inputDM.Date = inputVM.Date; inputDM.Quantity = inputVM.Quantity; inputDM.TotalPrice = inputVM.TotalPrice; inputDM.Address = inputVM.Address; inputDM.Township = inputVM.Township; inputDM.CreatedUserId = inputVM.CreatedUserId; inputDM.UpdatedUserId = inputVM.UpdatedUserId; long time = DateTime.Now.Ticks; inputDM.Version = time; inputDM.CreatedDate = time; inputDM.UpdatedDate = time; int result = 0; using (PHOTOLIODBContext context = new PHOTOLIODBContext()) { context.OrderDMs.Add(inputDM); result = context.SaveChanges(); } return(result); }
public List <UserVM> SelectList() { using (PHOTOLIODBContext context = new PHOTOLIODBContext()) { return(context.UserDMs.Where(w => w.IsDelete == false).Select(s => new UserVM { Id = s.Id, Version = s.Version, Profile = s.Profile, Name = s.Name, Password = s.Password, UserBio = s.UserBio, FullAddress = s.FullAddress, PhoneNo = s.PhoneNo, Email = s.Email, Photoshop = s.Photoshop, Photography = s.Photography, Illustrator = s.Illustrator, Media = s.Media, PremierePro = s.PremierePro, Lightroom = s.Lightroom, Burmese = s.Burmese, English = s.English, Chinese = s.Chinese, PackageTitle = s.PackageTitle, AboutPackage = s.AboutPackage, PackagePrice = s.PackagePrice, }).ToList()); } }
public int Save(UserVM vmEntity) { var file = vmEntity.ProfileImage; //byte[] imageByte = null; //BinaryReader reader = new BinaryReader(file.InputStream); //imageByte = reader.ReadBytes(file.ContentLength); string filename = string.Empty; if (file != null && file.ContentLength > 0) { filename = Path.GetFileName(file.FileName); string imgpath = Path.Combine(System.Web.Hosting.HostingEnvironment.MapPath("/UserProfiles/"), filename); file.SaveAs(imgpath); } UserDM dmEntity = new UserDM(); dmEntity.PositionId = vmEntity.PositionId; dmEntity.Profile = filename; dmEntity.Name = vmEntity.Name; dmEntity.Password = vmEntity.Password; dmEntity.UserBio = vmEntity.UserBio; dmEntity.FullAddress = vmEntity.FullAddress; dmEntity.PhoneNo = vmEntity.PhoneNo; dmEntity.Email = vmEntity.Email; dmEntity.CreatedUserId = vmEntity.CreatedUserId; dmEntity.UpdatedUserId = vmEntity.UpdatedUserId; dmEntity.Photoshop = vmEntity.Photoshop; dmEntity.Photography = vmEntity.Photography; dmEntity.Illustrator = vmEntity.Illustrator; dmEntity.Media = vmEntity.Media; dmEntity.PremierePro = vmEntity.PremierePro; dmEntity.Lightroom = vmEntity.Lightroom; dmEntity.Burmese = vmEntity.Burmese; dmEntity.English = vmEntity.English; dmEntity.Chinese = vmEntity.Chinese; dmEntity.PackageTitle = vmEntity.PackageTitle; dmEntity.AboutPackage = vmEntity.AboutPackage; dmEntity.PackagePrice = vmEntity.PackagePrice; long time = DateTime.Now.Ticks; dmEntity.Version = time; dmEntity.CreatedDate = time; dmEntity.UpdatedDate = time; int result = 0; //to know success using (PHOTOLIODBContext context = new PHOTOLIODBContext()) { context.UserDMs.Add(dmEntity); result = context.SaveChanges(); } return(result); }
public List <OrderVM> SelectList(int productId) { using (PHOTOLIODBContext context = new PHOTOLIODBContext()) { return(context.OrderDMs .GroupJoin(context.ProductDMs, o => o.ProductId, p => p.Id, (o, p) => new { o, p }) .Where(w => w.o.IsDelete == false && w.o.ProductId == productId).Select(s => new OrderVM { Id = s.o.Id, Version = s.o.Version, Date = s.o.Date, Quantity = s.o.Quantity, TotalPrice = s.o.TotalPrice, Address = s.o.Address, Township = s.o.Township, ProductName = s.p.FirstOrDefault().Name, Price = s.p.FirstOrDefault().Price, }) .ToList()); } }
public int Save(ProductVM productVM) { //using (PHOTOLIODBContext context = new PHOTOLIODBContext()) //{ // int count = context.ProductDMs.Where(w => w.IsDelete == false && w.Name == productVM.Name).Count(); // if (count > 0) // { // return 100; // } //} var file = productVM.ImageFile; //byte[] imageByte = null; //BinaryReader reader = new BinaryReader(file.InputStream); //imageByte = reader.ReadBytes(file.ContentLength); string filename = string.Empty; if (file != null && file.ContentLength > 0) { filename = Path.GetFileName(file.FileName); string imgpath = Path.Combine(System.Web.Hosting.HostingEnvironment.MapPath("/GALLERY/"), filename); file.SaveAs(imgpath); } long time = DateTime.Now.Ticks; ProductDM dmEntity = new ProductDM(); dmEntity.UserId = productVM.UserId; dmEntity.Photo = filename; dmEntity.Name = productVM.Name; dmEntity.Description = productVM.Description; dmEntity.Price = productVM.Price; dmEntity.CategoryId = productVM.CategoryId; dmEntity.Version = time; dmEntity.CreatedUserId = productVM.CreatedUserId; dmEntity.UpdatedUserId = productVM.UpdatedUserId; dmEntity.CreatedDate = time; dmEntity.UpdatedDate = time; int result = 0; using (PHOTOLIODBContext context = new PHOTOLIODBContext()) { context.ProductDMs.Add(dmEntity); result = context.SaveChanges(); } return(result); }
public List <ProductVM> GetProductsByUser(int id) { using (PHOTOLIODBContext context = new PHOTOLIODBContext()) { var products = context.ProductDMs.Where(x => x.UserId == id).Select(x => new ProductVM { Photo = x.Photo, Description = x.Description }).ToList(); return(products); } }
public int Update(UserVM inputVM) { var file = inputVM.ProfileImage; //byte[] imageByte = null; //BinaryReader reader = new BinaryReader(file.InputStream); //imageByte = reader.ReadBytes(file.ContentLength); string filename = string.Empty; if (file != null && file.ContentLength > 0) { filename = Path.GetFileName(file.FileName); string imgpath = Path.Combine(System.Web.Hosting.HostingEnvironment.MapPath("/UserProfiles/"), filename); file.SaveAs(imgpath); } using (PHOTOLIODBContext context = new PHOTOLIODBContext()) { long time = DateTime.Now.Ticks; return(context.UserDMs .Where(w => w.Id == inputVM.Id && w.Version == inputVM.Version) .Update(u => new UserDM { Profile = filename, Name = inputVM.Name, Password = inputVM.Password, UserBio = inputVM.UserBio, FullAddress = inputVM.FullAddress, PhoneNo = inputVM.PhoneNo, Email = inputVM.Email, Photoshop = inputVM.Photoshop, Photography = inputVM.Photography, Illustrator = inputVM.Illustrator, Media = inputVM.Media, PremierePro = inputVM.PremierePro, Lightroom = inputVM.Lightroom, Burmese = inputVM.Burmese, English = inputVM.English, Chinese = inputVM.Chinese, PackageTitle = inputVM.PackageTitle, AboutPackage = inputVM.AboutPackage, PackagePrice = inputVM.PackagePrice, Version = time, UpdatedUserId = inputVM.UpdatedUserId, UpdatedDate = time, })); } }
public List <CategoryVM> SelectList() { List <CategoryVM> list = new List <CategoryVM>(); using (PHOTOLIODBContext context = new PHOTOLIODBContext()) { return(list = context.CategoryDMs.Where(w => w.IsDelete == false).Select(s => new CategoryVM { Id = s.Id, Name = s.Name, Version = s.Version, }).ToList()); } }
public CategoryVM SelectById(int id) { using (PHOTOLIODBContext context = new PHOTOLIODBContext()) { return(context.CategoryDMs .Where(w => w.Id == id && w.IsDelete == false) .Select(s => new CategoryVM { Id = s.Id, Name = s.Name, Version = s.Version, }).FirstOrDefault()); } }
public List <ContactUsVM> SelectList() { using (PHOTOLIODBContext context = new PHOTOLIODBContext()) { return(context.ContactUsDMs.Where(w => w.IsDelete == false).Select(s => new ContactUsVM { Id = s.Id, Version = s.Version, Name = s.Name, Email = s.Email, Message = s.Message, }) .ToList()); } }
public int Delete(OrderVM inputVM) { using (PHOTOLIODBContext context = new PHOTOLIODBContext()) { long time = DateTime.Now.Ticks; return(context.OrderDMs.Where(w => w.Id == inputVM.Id && w.Version == inputVM.Version) .Update(u => new OrderDM { IsDelete = true, Version = time, UpdatedUserId = inputVM.UpdatedUserId, UpdatedDate = time, })); } }
public int Delete(ProductVM inputVM) { long time = DateTime.Now.Ticks; using (PHOTOLIODBContext context = new PHOTOLIODBContext()) { return(context.ProductDMs .Where(w => w.Id == inputVM.Id && w.Version == inputVM.Version) .Update(s => new ProductDM { IsDelete = true, Version = time, UpdatedDate = time, })); } }
public ContactUsVM selectById(int id) { using (PHOTOLIODBContext context = new PHOTOLIODBContext()) { return(context.ContactUsDMs .Where(w => w.Id == id && w.IsDelete == false) .Select(s => new ContactUsVM { Id = s.Id, Name = s.Name, Email = s.Email, Message = s.Message, Version = s.Version, }).FirstOrDefault()); } }
public int update(CategoryVM inputVM) { long time = DateTime.Now.Ticks; using (PHOTOLIODBContext context = new PHOTOLIODBContext()) { return(context.CategoryDMs .Where(w => w.Id == inputVM.Id && w.Version == inputVM.Version) .Update(s => new CategoryDM { Name = inputVM.Name, Version = time, UpdatedDate = time, })); } }
public int update(ContactUsVM inputVM) { long time = DateTime.Now.Ticks; using (PHOTOLIODBContext context = new PHOTOLIODBContext()) { return(context.ContactUsDMs .Where(w => w.Id == inputVM.Id && w.Version == inputVM.Version) .Update(s => new ContactUsDM { Name = inputVM.Name, Email = inputVM.Email, Message = inputVM.Message, Version = time, UpdatedDate = time, })); } }
public OrderVM SelectById(int id) { using (PHOTOLIODBContext context = new PHOTOLIODBContext()) { return(context.OrderDMs.Where(w => w.IsDelete == false && w.Id == id).Select(s => new OrderVM { Id = s.Id, Version = s.Version, ProductId = s.ProductId, UserId = s.UserId, Date = s.Date, Quantity = s.Quantity, TotalPrice = s.TotalPrice, Address = s.Address, Township = s.Township, }) .FirstOrDefault()); } }
public ProductVM SelectById(int id) { using (PHOTOLIODBContext context = new PHOTOLIODBContext()) { return(context.ProductDMs .Where(w => w.Id == id && w.IsDelete == false) .Select(s => new ProductVM { Id = s.Id, UserId = s.UserId, Photo = s.Photo, Name = s.Name, Description = s.Description, Price = s.Price, CategoryId = s.CategoryId, //CategoryName = s.CategoryName, Version = s.Version, }).FirstOrDefault()); } }
public UserVM LogIn(string email, string password) { using (PHOTOLIODBContext context = new PHOTOLIODBContext()) { return(context.UserDMs.Where(w => w.IsDelete == false && w.Email == email && w.Password == password) .Select(s => new UserVM { Id = s.Id, Profile = s.Profile, Name = s.Name, UserBio = s.UserBio, PhoneNo = s.PhoneNo, FullAddress = s.FullAddress, Email = s.Email, PositionId = s.PositionId }) .FirstOrDefault()); } }
public int Update(OrderVM inputVM) { using (PHOTOLIODBContext context = new PHOTOLIODBContext()) { long time = DateTime.Now.Ticks; return(context.OrderDMs.Where(w => w.Id == inputVM.Id && w.Version == inputVM.Version) .Update(u => new OrderDM { UserId = inputVM.UserId, ProductId = inputVM.ProductId, Date = inputVM.Date, Quantity = inputVM.Quantity, TotalPrice = inputVM.TotalPrice, Address = inputVM.Address, Township = inputVM.Township, Version = time, UpdatedUserId = inputVM.UpdatedUserId, UpdatedDate = time })); } }
public int Save(CategoryVM inputVM) { long time = DateTime.Now.Ticks; CategoryDM dmEntity = new CategoryDM(); dmEntity.Name = inputVM.Name; dmEntity.Version = time; dmEntity.CreatedUserId = inputVM.CreatedUserId; dmEntity.UpdatedUserId = inputVM.UpdatedUserId; dmEntity.CreatedDate = time; dmEntity.UpdatedDate = time; int result = 0; using (PHOTOLIODBContext context = new PHOTOLIODBContext()) { context.CategoryDMs.Add(dmEntity); result = context.SaveChanges(); } return(result); }
public int Update(ProductVM inputVM) { var file = inputVM.ImageFile; long time = DateTime.Now.Ticks; //byte[] imageByte = null; //BinaryReader reader = new BinaryReader(file.InputStream); //imageByte = reader.ReadBytes(file.ContentLength); string filename = string.Empty; if (file != null && file.ContentLength > 0) { filename = Path.GetFileName(file.FileName); string imgpath = Path.Combine(System.Web.Hosting.HostingEnvironment.MapPath("/GALLERY/"), filename); file.SaveAs(imgpath); } using (PHOTOLIODBContext context = new PHOTOLIODBContext()) { return(context.ProductDMs .Where(w => w.Id == inputVM.Id && w.Version == inputVM.Version) .Update(s => new ProductDM { Photo = filename, UserId = inputVM.UserId, Name = inputVM.Name, Description = inputVM.Description, Price = inputVM.Price, CategoryId = inputVM.CategoryId, UpdatedUserId = inputVM.UpdatedUserId, Version = time, UpdatedDate = time, })); } }