public IActionResult Create(string memberId, string productId) { var m = _context.member.SingleOrDefault(mb => mb.id == new Guid(memberId)); var mpro = _context.mem_product.Where(mpr => (mpr.member_code == m.member_code) && (mpr.id == new Guid(productId))).Count(); if (mpro == 0) { var pd = _context.product.SingleOrDefault(pdt => pdt.id == new Guid(productId)); var pgrp = _context.product_group.SingleOrDefault(pg => pg.product_group_code == pd.product_group_code); var ptyp = _context.product_type.SingleOrDefault(pt => (pt.product_type_code == pd.product_type_code) && (pt.product_group_code == pd.product_group_code)); mem_product mp = new mem_product(); mp.member_code = m.member_code; mp.product_code = pd.product_code; mp.x_status = "Y"; _context.Add(mp); _context.SaveChanges(); //var mpCount = _context.mem_product.Where(mj => (mj.member_code == m.member_code)).Count(); var mpMax = _context.mem_product.Where(mj => (mj.member_code == m.member_code)).Max(mj => mj.rec_no); return(Json(new { result = "success", rec_no = mpMax, mem_product_id = mp.id, product_group_desc = pgrp.product_group_desc, product_type_desc = ptyp.product_type_desc, product_desc = pd.product_desc })); } else { return(Json(new { result = "duplicate" })); } }
public async Task <IActionResult> Create([Bind("product_type_code,product_group_code,id,product_type_desc,rowversion,x_log,x_note,x_status")] product_type product_type) { _context.Add(product_type); await _context.SaveChangesAsync(); return(Json(new { result = "success" })); }
public IActionResult Create([Bind("album_code,album_date,album_desc,album_name,created_by,id,rowversion,x_log,x_note,x_status")] album album) { album.album_type = "V"; //video album.x_status = "Y"; album.created_by = "Administrator"; _context.Add(album); _context.SaveChanges(); var pImages = _context.pic_image.Where(p => (p.ref_doc_code == album.album_code) && (p.x_status == "N")).ToList(); if (pImages != null) { foreach (var pImage in pImages) { pImage.x_status = "Y"; _context.Update(pImage); } _context.SaveChanges(); var uploads = Path.Combine(_env.WebRootPath, _configuration.GetSection("Paths").GetSection("images_upload").Value); uploads = Path.Combine(uploads, album.album_code); DirectoryInfo di = new DirectoryInfo(uploads); if (di.Exists) { var dest = Path.Combine(_env.WebRootPath, _configuration.GetSection("Paths").GetSection("images_album").Value); dest = Path.Combine(dest, album.album_code); Directory.Move(uploads, dest); } } return(RedirectToAction("Index")); }
public async Task <IActionResult> Edit(string action, string member_code, string course_code, DateTime course_begin, int course_day) { var cdate = course_begin.AddDays(course_day - 1); try { if (action.Equals("add")) { var c = new project_daily_checklist(); c.member_code = member_code; c.course_code = course_code; c.course_date = cdate; c.x_status = "Y"; _context.Add(c); } else if (action.Equals("del")) { var c = _context.project_daily_checklist.SingleOrDefault(d => (d.member_code == member_code) && (d.course_code == course_code) && (d.course_date == cdate)); _context.Remove(c); } await _context.SaveChangesAsync(); } catch (Exception) { return(Json(new { result = "fail" })); } return(Json(new { result = "success" })); }
public IActionResult Edit(string memberId, string member_code, string medical_history, string blood_group, string hobby, string restrict_food, string special_skill) { ViewBag.memberId = memberId; mem_health mem_health = _context.mem_health.SingleOrDefault(m => m.member_code == member_code); if (mem_health == null) { mem_health mh = new mem_health(); mh.member_code = member_code; mh.medical_history = medical_history; mh.blood_group = blood_group; mh.hobby = hobby; mh.restrict_food = restrict_food; mh.special_skill = special_skill; mh.x_status = "Y"; _context.Add(mh); } else { mem_health mh = mem_health; mh.member_code = member_code; mh.medical_history = medical_history; mh.blood_group = blood_group; mh.hobby = hobby; mh.restrict_food = restrict_food; mh.special_skill = special_skill; mh.x_status = "Y"; _context.Update(mh); } _context.SaveChanges(); return(Json(new { result = "success" })); }
public async Task <IActionResult> Create([Bind("ctype_code,cgroup_code,ctype_desc,id,rowversion,x_log,x_note,x_status")] course_type course_type) { if (ModelState.IsValid) { _context.Add(course_type); await _context.SaveChangesAsync(); } return(Json(new { result = "success" })); }
public async Task <IActionResult> Create([Bind("cgroup_code,cgroup_desc,x_status")] course_group course_group) { if (ModelState.IsValid) { _context.Add(course_group); await _context.SaveChangesAsync(); } return(Json(new { result = "success" })); }
public async Task <IActionResult> Create([Bind("spon_code,confirm_date,contactor,contactor_detail,id,ref_doc,spon_desc,x_log,x_note,x_status")] project_sponsor project_sponsor) { if (ModelState.IsValid) { _context.Add(project_sponsor); await _context.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(project_sponsor)); }
public async Task <IActionResult> Create([Bind("product_code,member_code,grow_area,id,rowversion,x_log,x_note,x_status")] mem_product mem_product) { if (ModelState.IsValid) { _context.Add(mem_product); await _context.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(mem_product)); }
public async Task <IActionResult> Create([Bind("district_code,province_code,country_code,area_part,dist_desc,id,rowversion,x_log,x_note,x_status")] ini_district ini_district) { if (ModelState.IsValid) { _context.Add(ini_district); await _context.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(ini_district)); }
public async Task <IActionResult> Create([Bind("project_code,active_member_join,budget,id,passed_member,project_approve_date,project_date,project_desc,project_manager,ref_doc,target_member_join,x_log,x_note,x_status")] project project) { if (ModelState.IsValid) { _context.Add(project); await _context.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(project)); }
public async Task <IActionResult> Create([Bind("place_code,confirm_date,contactor,contactor_detail,id,place_desc,ref_doc,x_log,x_note,x_status")] train_place train_place) { if (ModelState.IsValid) { _context.Add(train_place); await _context.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(train_place)); }
public async Task <IActionResult> CourseCreate([Bind("course_code,active_member_join,budget,cgroup_code,charge_head,course_approve_date,course_begin,course_date,course_desc,course_end,ctype_code,id,passed_member,project_code,project_manager,ref_doc,support_head,target_member_join,x_log,x_note,x_status")] project_course project_course) { if (ModelState.IsValid) { _context.Add(project_course); await _context.SaveChangesAsync(); return(RedirectToAction("CourseIndex")); } return(View(project_course)); }
public async Task <IActionResult> Create([Bind("province_code,country_code,district_code,subdistrict_code,zip_code,id,rowversion,x_log,x_note,x_status")] ini_list_zip ini_list_zip) { if (ModelState.IsValid) { _context.Add(ini_list_zip); await _context.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(ini_list_zip)); }
public async Task <IActionResult> Create([Bind("product_group_code,id,product_group_desc,rowversion,x_log,x_note,x_status")] product_group product_group) { if (ModelState.IsValid) { _context.Add(product_group); await _context.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(product_group)); }
public async Task <IActionResult> Create([Bind("album_code,album_desc,album_name,created_by,album_date,rowversion")] album album) { album.x_status = "Y"; //album.album_code = DateTime.Now.ToString("yyMMddhhmmss"); album.created_by = "Administrator"; _context.Add(album); await _context.SaveChangesAsync(); return(RedirectToAction("Index")); }
public async Task <IActionResult> Create([Bind("client_code,system,module,cnfig_item,id,rowversion,text_value,x_log,x_note,x_status")] ini_config ini_config) { if (ModelState.IsValid) { _context.Add(ini_config); await _context.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(ini_config)); }
public async Task <IActionResult> Create([Bind("id,mem_testcenter_desc,rowversion,x_status")] mem_testcenter mem_testcenter) { if (ModelState.IsValid) { mem_testcenter.mem_testcenter_desc = mem_testcenter.mem_testcenter_desc.Trim(); mem_testcenter.id = Guid.NewGuid(); mem_testcenter.CreatedBy = new Guid(HttpContext.Session.GetString("memberId")); mem_testcenter.CreatedDate = DateTime.Now; mem_testcenter.x_status = mem_testcenter.x_status.Trim(); mem_testcenter.mem_testcenter_code = DateTime.Now.ToString("yyMMddhhmmss"); _context.Add(mem_testcenter); await _context.SaveChangesAsync(); } return(Json(new { result = "success" })); }
public async Task <IActionResult> Create(string placeId, string place_cost, string courseCode) { var i = _context.train_place.SingleOrDefault(m => m.id == new Guid(placeId)); course_train_place ci = new course_train_place(); ci.confirm_date = i.confirm_date; ci.course_code = courseCode; ci.place_code = i.place_code; ci.place_cost = Decimal.Parse(place_cost); ci.ref_doc = i.ref_doc; ci.x_status = i.x_status; try { _context.Add(ci); await _context.SaveChangesAsync(); } catch (Exception) { return(Json(new { result = "fail" })); } return(Json(new { result = "success" })); }
public async Task <IActionResult> Create(string sponsorId, string support_budget, string projectCode) { var psp = _context.project_sponsor.SingleOrDefault(pjs => pjs.id == new Guid(sponsorId)); project_supporter ps = new project_supporter(); ps.project_code = projectCode; ps.spon_code = psp.spon_code; ps.support_budget = Int32.Parse(support_budget); ps.contactor = psp.contactor; ps.contactor_detail = psp.contactor_detail; ps.x_status = psp.x_status; try { _context.Add(ps); await _context.SaveChangesAsync(); } catch (Exception) { return(Json(new { result = "fail" })); } return(Json(new { result = "success" })); }
public async Task <IActionResult> Register(string cid, string courseId) { project_course c = _context.project_course.SingleOrDefault(cc => cc.id == new Guid(courseId)); member m = _context.member.SingleOrDefault(mm => mm.cid_card == cid); int countReg = _context.project_course_register.Where(cr => cr.course_code == c.course_code).Count(); int targetReg = 0; if (c.target_member_join != null) { targetReg = (int)c.target_member_join; } else { targetReg = 999999999; } try { if (countReg < targetReg) { project_course_register pcr = new project_course_register(); pcr.course_code = c.course_code; pcr.member_code = m.member_code; pcr.x_status = "Y"; _context.Add(pcr); await _context.SaveChangesAsync(); } else { return(Json(new { result = "full", cid = cid })); } } catch (Exception) { return(Json(new { result = "fail", cid = cid })); } return(Json(new { result = "success", cid = cid })); }