public ServiceResult UpdateMaterialWithdraw(Material_Withdraw pWith) { try { using (var db = new AgnosDBContext()) { var current = db.Material_Withdraw.Where(w => w.Withdraw_ID == pWith.Withdraw_ID).FirstOrDefault(); if (current != null) { pWith.Update_On = currentdate; pWith.Update_By = userlogin.Email_Address; SaveProductMaping(db, pWith.Product_Code, pWith.Product_Name); db.Entry(current).CurrentValues.SetValues(pWith); db.SaveChanges(); } return(new ServiceResult() { Code = ReturnCode.SUCCESS, Msg = Success.GetMessage(ReturnCode.SUCCESS_UPDATE), Field = Resource.Material_Withdraw }); } } catch (Exception ex) { return(new ServiceResult() { Code = ReturnCode.ERROR_UPDATE, Msg = Error.GetMessage(ReturnCode.ERROR_UPDATE), Field = Resource.Material_Withdraw, Exception = ex }); } }
public ServiceResult InsertMaterialWithdraw(Material_Withdraw pWith) { try { using (var db = new AgnosDBContext()) { pWith.Create_On = currentdate; pWith.Create_By = userlogin.Email_Address; pWith.Update_On = currentdate; pWith.Update_By = userlogin.Email_Address; pWith.PLC = userlogin.Profile_ID; db.Material_Withdraw.Add(pWith); SaveProductMaping(db, pWith.Product_Code, pWith.Product_Name); db.SaveChanges(); db.Entry(pWith).GetDatabaseValues(); return(new ServiceResult() { Code = ReturnCode.SUCCESS, Msg = Success.GetMessage(ReturnCode.SUCCESS_INSERT), Field = Resource.Material_Withdraw }); } } catch (Exception ex) { return(new ServiceResult() { Code = ReturnCode.ERROR_INSERT, Msg = Error.GetMessage(ReturnCode.ERROR_INSERT), Field = Resource.Material_Withdraw, Exception = ex }); } }