public long Create(cust_mast customer) { using (var ctx = new ConXContext()) { using (TransactionScope scope = new TransactionScope()) { cust_mast newCust = new cust_mast() { cust_name = customer.cust_name, //surname = customer.surname, address1 = customer.address1, //address2 = customer.address2, subDistrict = customer.subDistrict, district = customer.district, province = customer.province, zipCode = customer.zipCode, status = "A", fax = customer.fax, tel = customer.tel, sex = customer.sex, line = customer.line, }; ctx.CustMasts.Add(newCust); ctx.SaveChanges(); scope.Complete(); return(newCust.customerId); } } }
public void Update(CustomerView model) { using (var ctx = new ConXContext()) { //string imagePath = @model.pic_file_path; //string imgBase64String = Util.Util.GetBase64StringForImage(imagePath); using (TransactionScope scope = new TransactionScope()) { cust_mast updateObj = ctx.CustMasts.Where(z => z.customerId == model.customerId).SingleOrDefault(); updateObj.cust_name = model.cust_name; updateObj.address1 = model.address1; updateObj.subDistrict = model.subDistrict; updateObj.district = model.district; updateObj.province = model.province; updateObj.zipCode = model.zipCode; updateObj.tel = model.tel; ctx.SaveChanges(); scope.Complete(); } } }
//public void SyncUpdate(cust_mast customer) //{ // using (var ctx = new ConXContext()) // { // using (TransactionScope scope = new TransactionScope()) // { // } // } //} public void Update(cust_mast customer) { using (var ctx = new ConXContext()) { using (TransactionScope scope = new TransactionScope()) { } } }
public long IsExitingCustomer(cust_mast cust) { using (var ctx = new ConXContext()) { cust_mast customer = ctx.CustMasts .Where(x => x.cust_name == cust.cust_name && x.address1 == cust.address1 //&& x.address2 == cust.address2 && x.subDistrict == cust.subDistrict && x.district == cust.district && x.province == cust.province && x.zipCode == cust.zipCode && x.tel == cust.tel ).SingleOrDefault(); return((customer != null) ? customer.customerId : 0); } }
public CustomerView GetInfo(int code) { using (var ctx = new ConXContext()) { cust_mast model = ctx.CustMasts .Where(z => z.customerId == code).SingleOrDefault(); return(new CustomerView { customerId = model.customerId, cust_name = model.cust_name, address1 = model.address1, subDistrict = model.subDistrict, district = model.district, province = model.province, zipCode = model.zipCode, tel = model.tel }); } }
public HttpResponseMessage postCreate(cust_mast model) { try { //check dupplicate Code //var isDupplicate = colorSvc.CheckDupplicate(model.menuFunctionId); //if (isDupplicate) //{ // return Request.CreateErrorResponse(HttpStatusCode.InternalServerError, string.Format("รหัสเมนู {0} มีอยู่ในระบบแล้ว", model.menuFunctionId)); //} customerService.Create(model); return(Request.CreateResponse(HttpStatusCode.OK, "บันทึกข้อมูลสำเร็จ")); } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.ToString())); } }
public void Delete(CustomerView custView) { using (var ctx = new ConXContext()) { using (TransactionScope scope = new TransactionScope()) { cust_mast cust = ctx.CustMasts .Where(z => z.customerId == custView.customerId) .SingleOrDefault(); //ctx.UserBranchPrvlgs.RemoveRange(ctx.UserBranchPrvlgs.Where(z => z.username == colorView.emb_color_mast_id)); //ctx.SaveChanges(); ctx.CustMasts.Remove(cust); ctx.SaveChanges(); scope.Complete(); } } }