public void updateCreateBatch(MasterBatchDetails batchDetails) { using (StudentManagementPortalEntities dbContext = new StudentManagementPortalEntities()) { try { BatchDeatil newBatch = dbContext.BatchDeatils.Find(batchDetails.BatchId); newBatch = newBatch == null? new BatchDeatil():newBatch; newBatch.BatchName = batchDetails.BatchName; newBatch.BatchStartDate = batchDetails.BatchStartDate; newBatch.Instructorname = batchDetails.Instructorname; newBatch.ModuleId = batchDetails.ModuleId; if (newBatch.BatchId == 0) { dbContext.BatchDeatils.Add(newBatch); } dbContext.SaveChanges(); } catch (Exception ex) { } } }
public void CreateUpdateBatch([FromBody] MasterBatchDetails batchDetails) { services = new AdminServices(); services.updateCreateBatch(batchDetails); }