Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
0
        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);
        }
Exemplo n.º 5
0
        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);
        }