public OperationResult Edit(Designer designer) { OperationResult result = new OperationResult(); try { AppleLaLaRepository <Designer> repository = new AppleLaLaRepository <Designer>(context); var inputData = new Designer { Designer_id = designer.Designer_id, Account = designer.Account, Name = designer.Name, Nickname = designer.Nickname, Birthday = designer.Birthday, Address = designer.Address, Mobile = designer.Mobile, Gender = designer.Gender, Hire_day = designer.Hire_day, Description = designer.Description, Photo_rul = designer.Photo_rul, Last_updata_date = DateTime.Now }; repository.Update(inputData); context.SaveChanges(); result.IsSuccessful = true; } catch (Exception ex) { result.IsSuccessful = false; result.exception = ex; } return(result); }
public OperationResult Edit(Banner banner) { OperationResult result = new OperationResult(); try { AppleLaLaRepository <Banner> repository = new AppleLaLaRepository <Banner>(context); var inputData = new Banner { Banner1 = banner.Banner1, Title = banner.Title, Sut_title = banner.Sut_title, Banner_photo_url = banner.Banner_photo_url, Text = banner.Text, Last_updata_date = DateTime.Now }; repository.Update(inputData); context.SaveChanges(); result.IsSuccessful = true; } catch (Exception ex) { result.IsSuccessful = false; result.exception = ex; } return(result); }
public OperationResult Edit(Customer customer) { OperationResult result = new OperationResult(); try { AppleLaLaRepository <Customer> repository = new AppleLaLaRepository <Customer>(context); var inputData = new Customer { Cust_id = customer.Cust_id, Account = customer.Account, Name = customer.Name, Birthday = customer.Birthday, Address = customer.Address, Mobile = customer.Mobile, Gender = customer.Gender, Last_updata_date = DateTime.Now, Coupon_id = customer.Coupon_id }; repository.Update(inputData); context.SaveChanges(); result.IsSuccessful = true; } catch (Exception ex) { result.IsSuccessful = false; result.exception = ex; } return(result); }
public ActionResult Create([Bind(Include = "Service_id,Service_name,Service_photo_url,Description")] Service service) { if (ModelState.IsValid) { db.Service.Add(service); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(service)); }
public ActionResult Create([Bind(Include = "Payway_id,Name")] Payway payway) { if (ModelState.IsValid) { db.Payway.Add(payway); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(payway)); }
public ActionResult Create([Bind(Include = "Coupon_id,Coupon_name,Discount")] Coupon coupon) { if (ModelState.IsValid) { db.Coupon.Add(coupon); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(coupon)); }
public ActionResult Edit([Bind(Include = "Protfolio_id,Designer_id,Service_details_Id,Photo_url,Year,Month,Color_type,Description,Create_date,Last_updata_date")] Protfolio protfolio) { if (ModelState.IsValid) { db.Entry(protfolio).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.Designer_id = new SelectList(db.Designer, "Designer_id", "Name", protfolio.Designer_id); ViewBag.Service_details_Id = new SelectList(db.Service_details, "Service_details_Id", "Name", protfolio.Service_details_Id); return(View(protfolio)); }
public ActionResult Create([Bind(Include = "Type_id,Type_name,Type_description,Service_id")] Service_types service_types) { if (ModelState.IsValid) { db.Service_types.Add(service_types); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.Service_id = new SelectList(db.Service, "Service_id", "Service_name", service_types.Service_id); return(View(service_types)); }
public ActionResult Create([Bind(Include = "Service_details_Id,Type_id,Name,Work_duration,Price,Discount_price,Description,Warranty_period,Photo,Unit")] Service_details service_details) { if (ModelState.IsValid) { db.Service_details.Add(service_details); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.Type_id = new SelectList(db.Service_types, "Type_id", "Type_name", service_details.Type_id); return(View(service_details)); }
public ActionResult Create([Bind(Include = "Cust_id,Coupon_id,End_day,Start_day")] Customer_coupon customer_coupon) { if (ModelState.IsValid) { db.Customer_coupon.Add(customer_coupon); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.Coupon_id = new SelectList(db.Coupon, "Coupon_id", "Coupon_name", customer_coupon.Coupon_id); ViewBag.Cust_id = new SelectList(db.Customer, "Cust_id", "Account", customer_coupon.Cust_id); return(View(customer_coupon)); }
public ActionResult Create([Bind(Include = "Order_id,Order_date,Cust_id,Payway_id,Last_updata_date")] Order order) { if (ModelState.IsValid) { db.Order.Add(order); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.Cust_id = new SelectList(db.Customer, "Cust_id", "Account", order.Cust_id); ViewBag.Payway_id = new SelectList(db.Payway, "Payway_id", "Name", order.Payway_id); return(View(order)); }
public ActionResult Create([Bind(Include = "Order_detail_no,Order_id,Service_details_Id,Appointment_date,Session_id,Designer_id,Coupon_id,Last_updata_date")] Order_details order_details) { if (ModelState.IsValid) { db.Order_details.Add(order_details); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.Order_id = new SelectList(db.Order, "Order_id", "Order_id", order_details.Order_id); ViewBag.Service_details_Id = new SelectList(db.Service_details, "Service_details_Id", "Name", order_details.Service_details_Id); return(View(order_details)); }
public ActionResult Create([Bind(Include = "Designer_id,Last_updata_date,Service_details_Id,Service_type_id,Service_id")] Designer_service designer_service) { if (ModelState.IsValid) { db.Designer_service.Add(designer_service); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.Designer_id = new SelectList(db.Designer, "Designer_id", "Account", designer_service.Designer_id); ViewBag.Service_id = new SelectList(db.Service, "Service_id", "Service_name", designer_service.Service_id); ViewBag.Service_details_Id = new SelectList(db.Service_details, "Service_details_Id", "Name", designer_service.Service_details_Id); ViewBag.Service_type_id = new SelectList(db.Service_types, "Type_id", "Type_name", designer_service.Service_type_id); return(View(designer_service)); }
public OperationResult CopyToCustomer(ExternalLoginConfirmationViewModel model) { OperationResult copyResult = new OperationResult(); try { AppleLaLaModel context = new AppleLaLaModel(); AppleLaLaRepository <Customer> repository = new AppleLaLaRepository <Customer>(context); var copyUser = new Customer { Name = model.Name, Account = model.Email, Birthday = model.Birthday, Address = model.Address, Mobile = model.PhoneNumber, Gender = model.Sex, Last_updata_date = DateTime.Now, }; repository.Create(copyUser); context.SaveChanges(); copyResult.IsSuccessful = true; } catch (Exception ex) { copyResult.IsSuccessful = false; copyResult.exception = ex; } return(copyResult); }
public OperationResult Create(Protfolio protfolio) { OperationResult result = new OperationResult(); try { AppleLaLaRepository <Protfolio> repo_p = new AppleLaLaRepository <Protfolio>(context); var CreateDate = new Protfolio { Designer_id = protfolio.Designer_id, Service_details_Id = protfolio.Service_details_Id, Photo_url = protfolio.Photo_url, Year = protfolio.Year, Month = protfolio.Month, Color_type = protfolio.Color_type, Description = protfolio.Description, Create_date = DateTime.Now, Last_updata_date = DateTime.Now, }; repo_p.Create(CreateDate); context.SaveChanges(); result.IsSuccessful = true; } catch (Exception ex) { result.IsSuccessful = false; result.exception = ex; } return(result); }
public ActionResult DeleteConfirmed(int id) { Customer customer = db.Customer.Find(id); db.Customer.Remove(customer); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult DeleteConfirmed(int id) { Designer designer = db.Designer.Find(id); db.Designer.Remove(designer); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Register(RegisterViewModel registerVM) { if (!ModelState.IsValid) { ModelState.AddModelError("", "無效"); return(View(registerVM)); } AppleLaLaRepository <Admin_accounts> repository = new AppleLaLaRepository <Admin_accounts>(context); Admin_accounts user = new Admin_accounts { UserName = HttpUtility.HtmlEncode(registerVM.UserName), Password = HashService.MD5Hash(HttpUtility.HtmlEncode(registerVM.Password)), }; context.Admin_accounts.Add(user); context.SaveChanges(); return(RedirectToAction("Index", "Home")); }
public void Update(T entity) { _context.Entry(entity).State = EntityState.Modified; _context.SaveChanges(); }
public void _intoDB(string cartInfo, string Status, string OrderNo, int PayWay_id, int cus_id) { var result = Newtonsoft.Json.JsonConvert.DeserializeObject <List <CartDetail> >(cartInfo); AppleLaLaRepository <Order> repo_order = new AppleLaLaRepository <Order>(context); AppleLaLaRepository <Order_details> repo_Order_details = new AppleLaLaRepository <Order_details>(context); AppleLaLaRepository <Work_schedule> repo_Work_schedule = new AppleLaLaRepository <Work_schedule>(context); Order _order = new Order { Order_id = OrderNo, Payway_id = PayWay_id, Cust_id = cus_id, Order_date = DateTime.Now, Last_updata_date = DateTime.Now, }; repo_order.Create(_order); context.SaveChanges(); var SessionId = 0; var time = 1; foreach (var item in result) { switch (int.Parse(item.Session)) { case 11: SessionId = 1; break; case 12: SessionId = 2; break; case 13: SessionId = 3; break; case 14: SessionId = 4; break; case 15: SessionId = 5; break; case 16: SessionId = 6; break; case 17: SessionId = 7; break; case 18: SessionId = 8; break; case 19: SessionId = 9; break; case 20: SessionId = 10; break; case 21: SessionId = 11; break; default: SessionId = 0; break; } Order_details order_Details = new Order_details() { Order_detail_no = DateTimeOffset.Now.AddSeconds(time).ToUnixTimeSeconds().ToString(), Order_id = OrderNo, Service_details_Id = (from sd in context.Service_details where sd.Name == item.Services select sd.Service_details_Id).First(), Appointment_date = item.Date, Session_id = SessionId, Designer_id = (from d in context.Designer where d.Name == item.Designer select d.Designer_id).First(), Last_updata_date = DateTime.Now, }; repo_Order_details.Create(order_Details); var cnstr = ConfigurationManager.ConnectionStrings["AppleLaLaModel"].ConnectionString; using (var conn = new SqlConnection(cnstr)) { conn.Open(); string sql = "select ws.Schedule_id, ws.Designer_id,ws.Date,ws.Session_id,ws.On_work_flag from[Work_schedule] ws inner join[Designer] d on ws.Designer_id = d.Designer_id where d.Name = @Name and ws.Date = @Date and ws.Session_id = @Session_id "; var target = conn.Query <dynamic>(sql, new { Name = item.Designer, Date = item.Date, Session_id = SessionId }); foreach (var i in target) { Work_schedule Work_schedule = new Work_schedule() { Schedule_id = i.Schedule_id, Designer_id = i.Designer_id, Date = i.Date, Session_id = i.Session_id, On_work_flag = "N" }; repo_Work_schedule.Update(Work_schedule); } } context.SaveChanges(); time++; } }
public OperationResult DataDesignerSchedule(List <Schedule_ViewModel> jsondata) { OperationResult result = new OperationResult(); try { AppleLaLaRepository <Work_schedule> repository = new AppleLaLaRepository <Work_schedule>(context); //List<Schedule_ViewModel> workflag = new List<Schedule_ViewModel>(); List <Work_schedule> wlist = new List <Work_schedule>(); int id = jsondata[0].Designer; var designerSchedules = context.Work_schedule.Where(x => x.Designer_id == id).ToList(); //這個設計師的所有行程(有很多天) foreach (var item in jsondata) { var Sessions = designerSchedules.Where(x => x.Date == item.Date).ToList(); //這個設計師這天的所有行程 foreach (var s in Sessions) { s.On_work_flag = "N"; //這個設計師這天的所有行程的是否上班轉換成"N" } foreach (var i in item.Sessions) { Sessions.FirstOrDefault(x => x.Session_id == i).On_work_flag = "Y"; //再依照jsondata這包從View收回來有上班的資料裡的sessions去找到這個session的是否上班轉換成"Y" } foreach (var s in Sessions) { repository.Update(s); //將這些是否上班都轉換正確後,Update(這裡的Update是資料庫裡的這個資料表裡逐筆資料row) } } ; context.SaveChanges(); result.IsSuccessful = true; //foreach (var item in jsondata) //畫面傳進來修改的所有List //{ // var designerId = item.Designer; //這個設計師Id // var date = item.Date; //這個設計師的這天 // var sessionArr = item.Sessions; //這個設計師這天的所有上班時段 //for (int i = 0; i < item.Sessions.Length; i++) //{ // workflag = context.Work_schedule //.Where(x => x.Designer_id == item.Designer) //.Where(x => x.Date == item.Date) //.Where(x => x.Session_id == item.Sessions[i]) //.Select(x => new Schedule_ViewModel //{ // Onwork = "Y" //}).ToList(); //} //}; //repository.Update(); //Work_schedule work_Schedule = new Work_schedule() //{ //}; } catch (Exception ex) { result.IsSuccessful = false; result.exception = ex; } //result.item = workflag; return(result); //var data2 = context.Work_schedule.Include(x => x.Designer).Include(x => x.Session) // .Select((x) => new DS_ViewModel // { // DesignerId = x.Designer_id, // Name = x.Designer.Name, // SessionId = x.Session_id, // WorkDate = x.Date, // WorkFlag = x.On_work_flag // }).ToList(); //var data = (from w in context.Work_schedule // join d in context.Designer on w.Designer_id equals d.Designer_id // join s in context.Session on w.Session_id equals s.Session_id // select new Designer_Schedule_ViewModel // { // //DesignerId = w.Designer_id, // Name = d.Name, // SessionId = w.Session_id, // WorkDate = w.Date, // WorkFlag = w.On_work_flag, // //Reference_order_detail = w.Reference_order_detail // } // ).ToList(); }