public void Delete(LaboratoryDTO laboratory) { if (_dbContext.Entry(laboratory).State == EntityState.Detached) { _dbSet.Attach(laboratory); } _dbSet.Remove(laboratory); }
public void Update(LaboratoryDTO laboratory) { var entity = _dbSet.SingleOrDefault(l => l.LabNumber == laboratory.LabNumber); if (entity != null) { entity = laboratory; } }
public LaboratoryModel Map(LaboratoryDTO laboratoryDTO) { if (laboratoryDTO == null) { return(null); } return(new LaboratoryModel { Id = laboratoryDTO.Id, LabNumber = laboratoryDTO.LabNumber, Date = laboratoryDTO.Date, Title = laboratoryDTO.Title, Curricula = laboratoryDTO.Curricula, Description = laboratoryDTO.Description }); }
public IHttpActionResult GetLabortorys(int filter) { var dt = bl.GetLabortorys(filter); LaboratoryModel labModel = new LaboratoryModel(); foreach (DataRow row in dt.Rows) { LaboratoryDTO lab = new LaboratoryDTO { id = int.Parse(row["id"].ToString()), name = row["name"].ToString() }; labModel.laboratory.Add(lab); } if (dt == null) { throw new HttpResponseException(Request.CreateResponse(HttpStatusCode.NotFound)); } return(Json(labModel)); }
public void Delete(int key) //delete dupa numarul labului { LaboratoryDTO labToDelete = _dbSet.SingleOrDefault(l => l.LabNumber == key); Delete(labToDelete); }
public void Add(LaboratoryDTO laboratory) { _dbSet.Add(laboratory); }