public HttpResponseMessage updatePersonelAtama(DTOAtama request) { using (var db = new CRMEntities()) using (var tran = db.Database.BeginTransaction()) try { var upa = db.atama.Where(r => r.id == request.id).FirstOrDefault(); upa.closedtasktype = request.closedtasktype; upa.closedtask = request.closedtask; upa.offpersonel = request.offpersonel; upa.formedtasktype = request.formedtasktype; upa.formedtask = request.formedtask; upa.appointedpersonel = request.appointedpersonel; db.SaveChanges(); tran.Commit(); var errormessage = new DTOResponseError { errorCode = 1, errorMessage = "Atama Düzenleme Tamamlandı." }; return(Request.CreateResponse(HttpStatusCode.OK, errormessage, "application/json")); } catch (Exception) { tran.Rollback(); var errormessage = new DTOResponseError { errorCode = 2, errorMessage = "Atama Düzenleme Tamamlanamadı!" }; return(Request.CreateResponse(HttpStatusCode.NotModified, errormessage, "application/json")); } }
public HttpResponseMessage insertPersonelAtama(DTOAtama request) { // yeni otomatik taska personel atama kuralı using (var db = new CRMEntities()) using (var tran = db.Database.BeginTransaction()) try { var errormessage = new DTOResponseError { errorCode = 1, errorMessage = "İşlem Başarılı" }; int arrayLenght; if (request.formedtaskarray != null) { arrayLenght = request.formedtaskarray.Length; } else { arrayLenght = 1; } for (int i = 0; i < arrayLenght; i++) { var p = new atama { closedtasktype = request.closedtasktype, closedtask = request.closedtask, offpersonel = request.offpersonel, formedtasktype = request.formedtasktype, formedtask = request.formedtaskarray != null ? request.formedtaskarray[i] : null, appointedpersonel = request.appointedpersonel, }; db.atama.Add(p); } db.SaveChanges(); tran.Commit(); return(Request.CreateResponse(HttpStatusCode.OK, errormessage, "application/json")); } catch (Exception) { tran.Rollback(); var errormessage = new DTOResponseError { errorCode = 2, errorMessage = "Hata Oluştu" }; return(Request.CreateResponse(HttpStatusCode.OK, errormessage, "application/json")); } }