public object Employeepayslip(Employeepayslip employeepayslip) { using (webdevContext webdev = new webdevContext()) { string msg = ""; bool IsSuccess = true; try { MongoDBServer mongoDB = new MongoDBServer(); var model = webdev.Employeepayslip.Where(a => a.BillId == employeepayslip.BillId).FirstOrDefault(); if (model != null) { model.BasePay = employeepayslip.BasePay; model.Deduction = employeepayslip.Deduction; model.Subsidy = employeepayslip.Subsidy; model.WagesPayable = employeepayslip.WagesPayable; model.Other = employeepayslip.Other; model.PayDate = employeepayslip.PayDate; model.Remarks = employeepayslip.Remarks; model.UserId = employeepayslip.UserId; webdev.Employeepayslip.Update(model); } else { webdev.Employeepayslip.Add(employeepayslip); } var i = webdev.SaveChanges(); if (i <= 0) { msg = "发生未知错误"; IsSuccess = false; } if (model != null) { mongoDB.db.GetCollection <Employeepayslip>("Employeepayslip").ReplaceOneAsync(a => a.BillId == employeepayslip.BillId, employeepayslip); } else { mongoDB.InsertOne <Employeepayslip>(employeepayslip, "Employeepayslip"); } } catch (Exception ex) { msg = ex.Message; IsSuccess = false; } return(new { IsSuccess = IsSuccess, msg = msg }); } }
public object EmployeeLeaveInsert(Employeeleave employeeLeave) { using (webdevContext webdev = new webdevContext()) { string msg = ""; bool IsSuccess = true; webdev.Employeeleave.Add(employeeLeave); var re = webdev.SaveChangesAsync(); msg = re.Exception?.Message; if (!string.IsNullOrEmpty(msg)) { IsSuccess = false; } if (re.Result > 0) { MongoDBServer mongoDB = new MongoDBServer(); mongoDB.InsertOne <Employeeleave>(employeeLeave, "EmployeeLeave"); } return(new { IsSuccess = IsSuccess, msg = msg }); } }