public Category CreateCategory(Category category)
 {
     category.AddedDate = DateTime.Now;
     _context.Categories.Add(category);
     _context.SaveChanges();
     return(category);
 }
 public IActionResult Create(Experience experience)
 {
     Console.WriteLine(experience.LocationId);
     db.Experiences.Add(experience);
     db.SaveChanges();
     return(RedirectToAction("Index"));
 }
 public Department CreateDepartment(Department department)
 {
     department.AddedDate = DateTime.Now;
     _context.Departments.Add(department);
     _context.SaveChanges();
     return(department);
 }
 public int Insert(FeedBack entity)
 {
     entity.Status     = false;
     entity.CreateDate = DateTime.Now;
     db.FeedBack.Add(entity);
     db.SaveChanges();
     return(entity.ID);
 }
        public long Insert(Product entity)
        {
            var systemConfig = new SystemConfigDAO().GetDetail(1);

            entity.CreatedDate = DateTime.Now;
            if (string.IsNullOrEmpty(entity.Image))
            {
                entity.Image = "none.png";
            }
            entity.ViewCount = 0;
            db.Product.Add(entity);
            db.SaveChanges();
            AddCode(entity.ID, entity.Duration, systemConfig.Prefix, systemConfig.Suffix, entity.Departure.ToShortDateString().Replace("/", ""));

            //Add tags
            if (!string.IsNullOrEmpty(entity.Tags))
            {
                string[] tags = entity.Tags.Split(',');

                foreach (var tag in tags)
                {
                    var tagID = StringHelper.ChangeText(tag);
                    if (!CheckTag(tagID))
                    {
                        this.InsertTag(tagID, tag);
                    }

                    this.InsertTagInProductTag(entity.ID, tagID);
                }
            }
            return(entity.ID);
        }
Пример #6
0
 public long Insert(Customer entity)
 {
     if (string.IsNullOrEmpty(entity.Image))
     {
         entity.Image = StringHelper.Radom_Avatar_Customer();
     }
     entity.Status = true;
     db.Customer.Add(entity);
     db.SaveChanges();
     return(entity.ID);
 }
 //Create
 public long InsertProductCategory(ProductCategory entity)
 {
     if (string.IsNullOrEmpty(entity.Image))
     {
         entity.Image = "none.png";
     }
     entity.CreatedDate = DateTime.Now;
     db.ProductCategory.Add(entity);
     db.SaveChanges();
     return(entity.ID);
 }
        public User Register(User user)
        {
            user.Password     = CryptoHelper.Crypto.HashPassword(user.Password);
            user.AddedDate    = DateTime.Now;
            user.ModifiedDate = DateTime.Now;
            user.AddedBy      = "System";
            user.ModifiedBy   = "System";

            _context.Users.Add(user);
            _context.SaveChanges();
            return(user);
        }
 public long Insert(Order entity)
 {
     entity.CreateDate   = DateTime.Now;
     entity.ModifiedDate = DateTime.Now;
     entity.Adult        = 0;
     entity.Baby         = 0;
     entity.Children     = 0;
     entity.Kid          = 0;
     entity.Status       = false;
     entity.Code         = entity.ProductID + entity.CreateDate.ToShortDateString().Replace("/", " ") + entity.Phone;
     db.Order.Add(entity);
     db.SaveChanges();
     return(entity.ID);
 }
        public void UpdateToken(int id, string token)
        {
            Admin admin = _context.Admins.Find(id);

            admin.Token = token;
            _context.SaveChanges();
        }
 public bool Update(SystemConfig sys)
 {
     try
     {
         var model = db.SystemConfig.Find(1);
         model.NameWebsite       = sys.NameWebsite;
         model.MetaWebsite       = sys.MetaWebsite;
         model.Description       = sys.Description;
         model.EmailManage       = sys.EmailManage;
         model.EmailNotification = sys.EmailNotification;
         model.NameCompany       = sys.NameCompany;
         model.Phone             = sys.Phone;
         model.Location          = sys.Location;
         model.Province          = sys.Province;
         model.Country           = sys.Country;
         model.Timezone          = sys.Timezone;
         model.Currency          = sys.Currency;
         model.Prefix            = sys.Prefix;
         model.Suffix            = sys.Suffix;
         model.CodeAnalytics     = sys.CodeAnalytics;
         model.Payment_terms     = sys.Payment_terms;
         db.SaveChanges();
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
Пример #12
0
 public int Insert(Menu mn)
 {
     if (string.IsNullOrEmpty(mn.Link))
     {
         mn.Link   = "/";
         mn.Target = "_blank";
     }
     else
     {
         mn.Link   = "/" + mn.Link;
         mn.Target = "_self";
     }
     db.Menu.Add(mn);
     db.SaveChanges();
     return(mn.ID);
 }
Пример #13
0
 public bool Update(Pay entity)
 {
     try
     {
         var model = db.Pay.Find(entity.ID);
         model.Name             = entity.Name;
         model.WebCode          = entity.WebCode;
         model.EmailPay         = entity.EmailPay;
         model.AccessCode       = entity.AccessCode;
         model.GuidePay         = entity.GuidePay;
         model.CodeAuthencation = entity.CodeAuthencation;
         model.CodeRepeat       = entity.CodeRepeat;
         model.AIPUserName      = entity.AIPUserName;
         model.AIPPassword      = entity.AIPPassword;
         model.AIPSignature     = entity.AIPSignature;
         model.AIPKey           = entity.AIPKey;
         model.Currency         = entity.Currency;
         model.Terminalld       = entity.Terminalld;
         model.MerchantAccount  = entity.MerchantAccount;
         model.HashCode         = entity.HashCode;
         model.Disable          = entity.Disable;
         model.Enable           = entity.Enable;
         model.Visitor          = entity.Visitor;
         model.Status           = entity.Status;
         db.SaveChanges();
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
 public bool Insert(Discount entity)
 {
     try
     {
         db.Discount.Add(entity);
         entity.Status = true;
         db.SaveChanges();
         if (entity.Status == true)
         {
             // change discount price in product
             var product = db.Product.Where(x => x.CategoryID == entity.ProductCategoryID);
             if (entity.Disprice > 0)
             {
                 foreach (var item in product)
                 {
                     item.PromotionPrice = (decimal)item.Price - (decimal)entity.Disprice;
                 }
             }
             else if (entity.Dispercent > 0 && entity.Dispercent <= 100)
             {
                 foreach (var item in product)
                 {
                     item.PromotionPrice = item.Price - ((item.Price * (decimal)entity.Dispercent) / 100);
                 }
             }
             db.SaveChanges();
         }
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
Пример #15
0
 public void SetUp()
 {
     _userGuid1 = Guid.NewGuid();
     _userGuid2 = Guid.NewGuid();
     _context   = TravelContextFactory.Create();
     _context.Travels.Add(ArrangeData());
     _context.SaveChanges();
     _handler = new GetTravelQueryHandler(_context);
 }
        public IActionResult Create(Experience experience)
        {
            db.Experiences.Add(experience);

            var thisPersonId = Int32.Parse(Request.Form["PersonId"]);
            var thisPerson   = db.People.FirstOrDefault(People => People.PersonId == thisPersonId);

            thisPerson.ExperienceId = experience.ExperienceId;
            var thisExperiencePeople = new ExperiencePeople {
            };

            thisExperiencePeople.ExperienceId = experience.ExperienceId;
            thisExperiencePeople.PersonId     = thisPerson.PersonId;
            db.ExperiencePeople.Add(thisExperiencePeople);

            db.Entry(thisPerson).State = EntityState.Modified;
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public bool Update(SystemNotification entity)
 {
     try
     {
         var model = db.SystemNotification.Find(entity.ID);
         model.Pattern      = entity.Pattern;
         model.Content      = entity.Content;
         model.EmailTitle   = entity.EmailTitle;
         model.EmailContent = entity.EmailContent;
         db.SaveChanges();
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
Пример #18
0
 public bool Update(Theme entity)
 {
     try
     {
         var model = db.Theme.Find(1);
         if (string.IsNullOrEmpty(entity.Header_image))
         {
             entity.Header_image = "slide.jpg";
         }
         if (string.IsNullOrEmpty(entity.Home_Number_Blog.ToString()))
         {
             entity.Home_Number_Blog = 3;
         }
         if (string.IsNullOrEmpty(entity.Home_Number_P.ToString()))
         {
             entity.Home_Number_Blog = 3;
         }
         model.Header_image          = entity.Header_image;
         model.Header_Description    = entity.Header_Description;
         model.Home_Title_P          = entity.Home_Title_P;
         model.Home_Description_P    = entity.Home_Description_P;
         model.Home_Title_Blog       = entity.Home_Title_Blog;
         model.Home_Description_Blog = entity.Home_Description_Blog;
         model.Product_Title         = entity.Product_Title;
         model.Product_Description   = entity.Product_Description;
         model.BLog_Title            = entity.BLog_Title;
         model.Blog_Description      = entity.Blog_Description;
         model.Feedback_Title        = entity.Feedback_Title;
         model.Feedback_Description  = entity.Feedback_Description;
         model.Footer_About          = entity.Footer_About;
         model.Footer_facebook_Link  = entity.Footer_facebook_Link;
         model.Footer_twitter_Link   = entity.Footer_twitter_Link;
         model.Footer_youtube_Link   = entity.Footer_youtube_Link;
         model.Footer_instagram_Link = entity.Footer_instagram_Link;
         model.Footer_Copyright      = entity.Footer_Copyright;
         model.Footer_Author         = entity.Footer_Author;
         model.Home_Number_Blog      = entity.Home_Number_Blog;
         model.Home_Number_P         = entity.Home_Number_P;
         db.SaveChanges();
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
Пример #19
0
        public long InsertNewsletter(Newsletter entity)
        {
            if (string.IsNullOrEmpty(entity.Image))
            {
                entity.Image = "none.png";
            }
            entity.CreatedDate = DateTime.Now;
            entity.ViewCount   = 0;
            entity.Like        = 0;
            entity.Angry       = 0;
            entity.Sad         = 0;
            entity.Glad        = 0;
            entity.Love        = 0;
            entity.Enjoy       = 0;
            entity.Scare       = 0;
            db.Newsletter.Add(entity);
            db.SaveChanges();

            //Add tags
            if (!string.IsNullOrEmpty(entity.Tags))
            {
                string[] tags = entity.Tags.Split(',');

                foreach (var tag in tags)
                {
                    var tagID = StringHelper.ChangeText(tag);
                    if (!CheckTag(tagID))
                    {
                        this.InsertTag(tagID, tag);
                    }
                    if (!CheckTagInNewsTag(entity.ID, tagID))
                    {
                        InsertNewsletterTag(entity.ID, tagID);
                    }
                }
            }
            return(entity.ID);
        }
Пример #20
0
 public IActionResult Create(Person person)
 {
     db.People.Add(person);
     db.SaveChanges();
     return(RedirectToAction("Index"));
 }
Пример #21
0
 public IActionResult Create(Experience experience)
 {
     db.Experiences.Add(experience);
     db.SaveChanges();
     return(RedirectToAction("Index"));
 }
Пример #22
0
 public IActionResult Create(Location location)
 {
     db.Locations.Add(location);
     db.SaveChanges();
     return(RedirectToAction("Index"));
 }
Пример #23
0
 public int Insert(MenuType entity)
 {
     db.MenuType.Add(entity);
     db.SaveChanges();
     return(entity.ID);
 }
 public int Insert(Domain entity)
 {
     db.Domain.Add(entity);
     db.SaveChanges();
     return(entity.ID);
 }
Пример #25
0
 public IActionResult Edit(Place place)
 {
     db.Entry(place).State = EntityState.Modified;
     db.SaveChanges();
     return(RedirectToAction("Index"));
 }
 public long Insert(Visitor entity)
 {
     db.Visitor.Add(entity);
     db.SaveChanges();
     return(entity.ID);
 }
 //Written log in admin pages when user using System admin
 public long InsertLog(Log_Admin entity)
 {
     db.Log_Admin.Add(entity);
     db.SaveChanges();
     return(entity.ID);
 }
 public IActionResult Create(Place place)
 {
     db.Places.Add(place);
     db.SaveChanges();
     return(RedirectToAction("Index"));
 }
 public long InsertUser(User entity)
 {
     db.User.Add(entity);
     db.SaveChanges();
     return(entity.ID);
 }