public void updateFile(Files file, Boolean bol) { FormFile formFile = new FormFile(); if (!bol) { context.Entry(file).State = EntityState.Added; context.SaveChanges(); formFile.fileid = file.fileid; m_formFileResponsitory.insertFormFile(formFile); } else { formFile = context.FormFile.Where(m => m.fileid == file.fileid).FirstOrDefault(); if (formFile == null) { formFile = new FormFile(); formFile.fileid = file.fileid; m_formFileResponsitory.insertFormFile(formFile); } context.Update(file); context.SaveChanges(); } }